&to_json_shim &to_json_protecttags
&set_ctype_utf8 &webdatadir
&expected_error &dbw_lookup_string
- &printable &tr_datarow
+ &printable &tr_datarow &escerrq
&prettyprint_age &meta_prettyprint_age);
%EXPORT_TAGS = ( );
}
}
+sub escerrq ($) {
+ return '“'.CGI::escapeHTML($_[0]).'”';
+# return '‘'.CGI::escapeHTML($_[0]).'’';
+}
+
package CommodsWeb::ExpectedError;
sub emsg ($) {
FROM commods WHERE commodname LIKE ?");
my ($emsg,$commod,@umv)=
dbw_lookup_string($spec,$commodsth,1,0,0,
- "No commodity or unit matches \`$spec'",
- "Ambiguous commodity (or unit) \`$spec'",
- undef);
+ "No commodity or unit matches ".escerrq($spec),
+ "Ambiguous commodity (or unit) ".escerrq($spec),
+ undef);
expected_error($emsg) if defined $emsg;
$debugf->("VALUE COMMOD FOUND '$commod' @umv");
foreach my $mvi (0,1) {
push @canon, $commod;
} else {
s/\s+$//;
- expected_error("Did not understand value \`$_'");
+ expected_error("Did not understand value ".
+ escerrq($_));
}
}
};
push @canon, sprintf "%g%%", $pct;
} elsif (!m/[^a-z]/i) {
$debugf->("TERM NAME");
- expected_error("Name (should be unit or commodity) \`$_'".
+ expected_error("Name (should be unit or commodity)".
+ escerrq($_).
" without preceding quantity")
unless $first_term;
my $sth= $dbh->prepare("SELECT name,mass,volume".
" FROM vessels WHERE name LIKE ?");
my ($emsg,$ship,@smv)=
dbw_lookup_string($_,$sth,1,1,2,
- "Ship name `$_' not understood.",
+ "Ship name ".escerrq($_)." not understood.",
"Too many matching ship types.",
sub { "Ambiguous - could be $_[1]" });
expected_error($emsg) if defined $emsg;
$capital= $1;
$canon= "$capital PoE";
} else {
- expected_error("Cannot understand capital \`$_'.");
+ expected_error("Cannot understand capital ".escerrq($_).".");
}
return ($canon,$capital);
</%method>
<%method nomatch>
- no commodity matches "<% $ARGS{spec} |h %>"
+ no commodity matches <% $ARGS{specq} %>
</%method>
<%method ambiguous>
- ambiguous commodity "<% $ARGS{spec} |h %>",
+ ambiguous commodity <% $ARGS{specq} %>,
could be <% $ARGS{couldbe} |h %>
</%method>
$leagues= $1;
$canon= "$leagues leagues";
} else {
- expected_error("Cannot understand distance \`$_'.");
+ expected_error("Cannot understand distance ".escerrq($_).".");
}
return ($canon,$leagues);
</%method>
<%method nomatch>
- no island matches "<% $ARGS{spec} |h %>"
+ no island matches <% $ARGS{specq} %>
</%method>
<%method ambiguous>
- ambiguous island "<% $ARGS{spec} |h %>",
+ ambiguous island <% $ARGS{specq} %>,
could be <% $ARGS{couldbe} |h %>
</%method>
$pct= 100.0/$1;
$str= sprintf("1/%d", $1);
} else {
- expected_error("Cannot understand loss per league \`$_'.");
+ expected_error("Cannot understand loss per league ".escerrq($_).".");
}
return ("$str per league", $pct);
</%method>
<%method nomatch>
- no island or arch matches "<% $ARGS{spec} |h %>"
+ no island or arch matches <% $ARGS{specq} %>
</%method>
<%method ambiguous>
- ambiguous island or arch "<% $ARGS{spec} |h %>",
+ ambiguous island or arch <% $ARGS{specq} %>,
could be <% $ARGS{couldbe} |h %>
</%method>
$dbh ||= ($mydbh= dbw_connect($ocean));
my $debugf= !$debug ? sub { } : sub {
- print "@_\n";
+ print escapeHTML("@_")."\n";
};
$debugf->("QTSC STRING '$string'");
$sth, $sqlstmt_nqs,
$chk->attr_exists('abbrev_initials'),
$chk->attr('maxambig'),
- $chk->scall_method("nomatch", spec => $each),
+ $chk->scall_method("nomatch", specq => escerrq($each)),
$chk->scall_method("manyambig"),
sub {
$chk->scall_method("ambiguous",
- spec => $each, couldbe => $_[1])
+ specq => escerrq($each),
+ couldbe => $_[1])
});
if (defined $temsg) {
$emsg= $temsg;
% $da_ages{'id_loaded'}= 0;
% my $rowix= 0;
% while ($row= $fetchrow->()) {
-% print STDERR "$row\n";
% my $rowid= "id_$row->{'islandid'}";
% my $cellid= "c$rowid";
% my $age= $now - $row->{'timestamp'};