chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.web-live.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eb4dd35
)
Properly quote various error messages
author
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Sat, 31 Oct 2009 19:09:50 +0000
(19:09 +0000)
committer
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Sat, 31 Oct 2009 19:09:50 +0000
(19:09 +0000)
yarrg/CommodsWeb.pm
patch
|
blob
|
history
yarrg/web/check_capacitystring
patch
|
blob
|
history
yarrg/web/check_capitalstring
patch
|
blob
|
history
yarrg/web/check_commodstring
patch
|
blob
|
history
yarrg/web/check_distance
patch
|
blob
|
history
yarrg/web/check_islandstring
patch
|
blob
|
history
yarrg/web/check_lossperleague
patch
|
blob
|
history
yarrg/web/check_routestring
patch
|
blob
|
history
yarrg/web/qtextstringcheck
patch
|
blob
|
history
yarrg/web/query_age
patch
|
blob
|
history
diff --git
a/yarrg/CommodsWeb.pm
b/yarrg/CommodsWeb.pm
index ab2a4a30a322e002135422a558eb1ecaff0b4c3e..461a8ad49332da3d232121822012e0002ecb00dc 100644
(file)
--- a/
yarrg/CommodsWeb.pm
+++ b/
yarrg/CommodsWeb.pm
@@
-52,7
+52,7
@@
BEGIN {
&to_json_shim &to_json_protecttags
&set_ctype_utf8 &webdatadir
&expected_error &dbw_lookup_string
&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 = ( );
&prettyprint_age &meta_prettyprint_age);
%EXPORT_TAGS = ( );
@@
-222,6
+222,11
@@
sub tr_datarow ($$) {
}
}
}
}
+sub escerrq ($) {
+ return '“'.CGI::escapeHTML($_[0]).'”';
+# return '‘'.CGI::escapeHTML($_[0]).'’';
+}
+
package CommodsWeb::ExpectedError;
sub emsg ($) {
package CommodsWeb::ExpectedError;
sub emsg ($) {
diff --git
a/yarrg/web/check_capacitystring
b/yarrg/web/check_capacitystring
index 52eab28264836ca8208e49a82a16db9beb8e3597..b958dff46745e2ee4c4b3b8efdbaffce92c07c8b 100644
(file)
--- a/
yarrg/web/check_capacitystring
+++ b/
yarrg/web/check_capacitystring
@@
-96,9
+96,9
@@
my $parse_values= sub {
FROM commods WHERE commodname LIKE ?");
my ($emsg,$commod,@umv)=
dbw_lookup_string($spec,$commodsth,1,0,0,
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) {
expected_error($emsg) if defined $emsg;
$debugf->("VALUE COMMOD FOUND '$commod' @umv");
foreach my $mvi (0,1) {
@@
-109,7
+109,8
@@
my $parse_values= sub {
push @canon, $commod;
} else {
s/\s+$//;
push @canon, $commod;
} else {
s/\s+$//;
- expected_error("Did not understand value \`$_'");
+ expected_error("Did not understand value ".
+ escerrq($_));
}
}
};
}
}
};
@@
-131,14
+132,15
@@
my $parse_term= sub {
push @canon, sprintf "%g%%", $pct;
} elsif (!m/[^a-z]/i) {
$debugf->("TERM NAME");
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,
" 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;
"Too many matching ship types.",
sub { "Ambiguous - could be $_[1]" });
expected_error($emsg) if defined $emsg;
diff --git
a/yarrg/web/check_capitalstring
b/yarrg/web/check_capitalstring
index 53aceecd975dcfacd3255f2cbbd51f8d29e04a29..24617d70c32c4d195099a98015bc11a65d1bec0f 100644
(file)
--- a/
yarrg/web/check_capitalstring
+++ b/
yarrg/web/check_capitalstring
@@
-53,7
+53,7
@@
if (!m/\S/) {
$capital= $1;
$canon= "$capital PoE";
} else {
$capital= $1;
$canon= "$capital PoE";
} else {
- expected_error("Cannot understand capital
\`$_'
.");
+ expected_error("Cannot understand capital
".escerrq($_)."
.");
}
return ($canon,$capital);
}
return ($canon,$capital);
diff --git
a/yarrg/web/check_commodstring
b/yarrg/web/check_commodstring
index de7cda8cb525848bfcf54498622ba8a40f6e267f..a6aa7267162499296286a6a0639ee6365acdb2a7 100644
(file)
--- a/
yarrg/web/check_commodstring
+++ b/
yarrg/web/check_commodstring
@@
-45,11
+45,11
@@
SELECT commodname,commodid
</%method>
<%method nomatch>
</%method>
<%method nomatch>
- no commodity matches
"<% $ARGS{spec} |h %>"
+ no commodity matches
<% $ARGS{specq} %>
</%method>
<%method ambiguous>
</%method>
<%method ambiguous>
- ambiguous commodity
"<% $ARGS{spec} |h %>"
,
+ ambiguous commodity
<% $ARGS{specq} %>
,
could be <% $ARGS{couldbe} |h %>
</%method>
could be <% $ARGS{couldbe} |h %>
</%method>
diff --git
a/yarrg/web/check_distance
b/yarrg/web/check_distance
index 223cc5a8f99509ab07ad226abbed2a127e1e7c3c..4d1a4e31831faa91dbbeb0b3630ee3bb8b7585ac 100644
(file)
--- a/
yarrg/web/check_distance
+++ b/
yarrg/web/check_distance
@@
-59,7
+59,7
@@
if (!m/\S/) {
$leagues= $1;
$canon= "$leagues leagues";
} else {
$leagues= $1;
$canon= "$leagues leagues";
} else {
- expected_error("Cannot understand distance
\`$_'
.");
+ expected_error("Cannot understand distance
".escerrq($_)."
.");
}
return ($canon,$leagues);
}
return ($canon,$leagues);
diff --git
a/yarrg/web/check_islandstring
b/yarrg/web/check_islandstring
index e8664d5788b54349780d6cf2d2893fc0efd34f52..bb33db100ec2262f393cf424485d8fd637e49fad 100644
(file)
--- a/
yarrg/web/check_islandstring
+++ b/
yarrg/web/check_islandstring
@@
-45,11
+45,11
@@
maxambig => 5
</%method>
<%method nomatch>
</%method>
<%method nomatch>
- no island matches
"<% $ARGS{spec} |h %>"
+ no island matches
<% $ARGS{specq} %>
</%method>
<%method ambiguous>
</%method>
<%method ambiguous>
- ambiguous island
"<% $ARGS{spec} |h %>"
,
+ ambiguous island
<% $ARGS{specq} %>
,
could be <% $ARGS{couldbe} |h %>
</%method>
could be <% $ARGS{couldbe} |h %>
</%method>
diff --git
a/yarrg/web/check_lossperleague
b/yarrg/web/check_lossperleague
index 937535521dd4209a254a7efa2d9d81464f6b2527..a37382e3a48aec5f61ae86eb2562d7c7647f50e4 100644
(file)
--- a/
yarrg/web/check_lossperleague
+++ b/
yarrg/web/check_lossperleague
@@
-54,7
+54,7
@@
if (!m/\S/) {
$pct= 100.0/$1;
$str= sprintf("1/%d", $1);
} else {
$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);
}
return ("$str per league", $pct);
diff --git
a/yarrg/web/check_routestring
b/yarrg/web/check_routestring
index cfa7ec72303e2ea671acb4ef28aa7de9cdedb662..6741eaedec9db07656b66a55e6051992b6219961 100644
(file)
--- a/
yarrg/web/check_routestring
+++ b/
yarrg/web/check_routestring
@@
-47,11
+47,11
@@
UNION ALL SELECT DISTINCT archipelago,NULL,archipelago
</%method>
<%method nomatch>
</%method>
<%method nomatch>
- no island or arch matches
"<% $ARGS{spec} |h %>"
+ no island or arch matches
<% $ARGS{specq} %>
</%method>
<%method ambiguous>
</%method>
<%method ambiguous>
- ambiguous island or arch
"<% $ARGS{spec} |h %>"
,
+ ambiguous island or arch
<% $ARGS{specq} %>
,
could be <% $ARGS{couldbe} |h %>
</%method>
could be <% $ARGS{couldbe} |h %>
</%method>
diff --git
a/yarrg/web/qtextstringcheck
b/yarrg/web/qtextstringcheck
index 9dce8287e208d8213418dd6432e49898c998a74a..0a75f8e9b6ae71be9f50117c542733c9ce71e787 100755
(executable)
--- a/
yarrg/web/qtextstringcheck
+++ b/
yarrg/web/qtextstringcheck
@@
-65,7
+65,7
@@
my $mydbh;
$dbh ||= ($mydbh= dbw_connect($ocean));
my $debugf= !$debug ? sub { } : sub {
$dbh ||= ($mydbh= dbw_connect($ocean));
my $debugf= !$debug ? sub { } : sub {
- print
"@_
\n";
+ print
escapeHTML("@_")."
\n";
};
$debugf->("QTSC STRING '$string'");
};
$debugf->("QTSC STRING '$string'");
@@
-105,11
+105,12
@@
if ($chk->method_exists('execute')) {
$sth, $sqlstmt_nqs,
$chk->attr_exists('abbrev_initials'),
$chk->attr('maxambig'),
$sth, $sqlstmt_nqs,
$chk->attr_exists('abbrev_initials'),
$chk->attr('maxambig'),
- $chk->scall_method("nomatch", spec
=> $each
),
+ $chk->scall_method("nomatch", spec
q => escerrq($each)
),
$chk->scall_method("manyambig"),
sub {
$chk->scall_method("ambiguous",
$chk->scall_method("manyambig"),
sub {
$chk->scall_method("ambiguous",
- spec => $each, couldbe => $_[1])
+ specq => escerrq($each),
+ couldbe => $_[1])
});
if (defined $temsg) {
$emsg= $temsg;
});
if (defined $temsg) {
$emsg= $temsg;
diff --git
a/yarrg/web/query_age
b/yarrg/web/query_age
index fd2044d97b4463457d88776b71dc0000b45590ea..efd709692a855426a1ae3f7ca819a2f009ce8b4f 100644
(file)
--- a/
yarrg/web/query_age
+++ b/
yarrg/web/query_age
@@
-81,7
+81,6
@@
$sth->execute();
% $da_ages{'id_loaded'}= 0;
% my $rowix= 0;
% while ($row= $fetchrow->()) {
% $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'};
% my $rowid= "id_$row->{'islandid'}";
% my $cellid= "c$rowid";
% my $age= $now - $row->{'timestamp'};