Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
SECURITY: routes.php: Escape input values when output verbatim
  • Loading branch information
jpatokal authored Aug 22, 2024
2 parents 453ef32 + 4460a16 commit 92f2431
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions php/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
default:
die(_('Error') . ';' .
sprintf(
_('Query %s not understood. For airlines, please enter a 2-letter IATA code. For airports, please enter a 3-letter IATA or 4-letter ICAO code.'),
$param
_("Query '%s' not understood. For airlines, please enter a 2-letter IATA code. For airports, please enter a 3-letter IATA or 4-letter ICAO code."),
htmlspecialchars($param)
));
}
$sth = $dbh->prepare($sql);
$sth->execute([$param]);
$row = $sth->fetch();
if (!$row) {
die(_('Error') . ';' . sprintf(_('No match found for query %s'), $param));
die(_('Error') . ';' . sprintf(_("No match found for query '%s'"), htmlspecialchars($param)));
}

$apid = $row["apid"];
Expand Down Expand Up @@ -90,7 +90,7 @@
$sth->execute($params);
$row = $sth->fetch();
if (!$row) {
die(_('Error') . ';' . sprintf(_('Error;No airport with ID %s found'), $apid));
die(_('Error') . ';' . sprintf(_("Error;No airport with ID '%s' found"), htmlspecialchars($apid)));
}

printf(
Expand Down Expand Up @@ -131,7 +131,7 @@
$sth->execute([$apid]);
$row = $sth->fetch();
if (!$row) {
die(_('Error') . ';' . sprintf(_('Error;No airline with ID %s found'), $apid));
die(_('Error') . ';' . sprintf(_("Error;No airline with ID '%s' found"), htmlspecialchars($apid)));
}

printf(
Expand Down Expand Up @@ -224,7 +224,7 @@
if ($type == "L") {
// Special handling here: no "all" option, alid = 0 means exclude codeshares, alid != 0 means codeshares also
$map .= sprintf("NOALL\t%s;%s\t", 0, $alname . _("-operated"));
$map .= sprintf("%s;%s", $apid . "C", $alname . _(" and codeshares"));
$map .= sprintf("%s;%s", htmlspecialchars($apid) . "C", $alname . _(" and codeshares"));
} else {
// Note: Existing airline filter is purposely ignored here
$sql = "SELECT DISTINCT a.alid, iata, icao, name FROM airlines as a, routes as r
Expand Down

0 comments on commit 92f2431

Please sign in to comment.