Skip to content

Commit 69e66ea

Browse files
committed
Autocomplete: Escape HTML tags in callback name to avoid XSS in demo
Fixes #15048
1 parent c571d2f commit 69e66ea

File tree

Image for: File tree

1 file changed

Image for: 1 file changed
+4
-1
lines changed

1 file changed

Image for: 1 file changed
+4
-1
lines changed

‎demos/autocomplete/search.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@
586586
$output = json_encode($result);
587587

588588
if ($_GET["callback"]) {
589-
$output = $_GET["callback"] . "($output);";
589+
// Escape special characters to avoid XSS attacks via direct loads of this
590+
// page with a callback that contains HTML. This is a lot easier than validating
591+
// the callback name.
592+
$output = htmlspecialchars($_GET["callback"]) . "($output);";
590593
}
591594

592595
echo $output;

0 commit comments

Image for: 0 commit comments
Comments
 (0)