Skip to content

Instantly share code, notes, and snippets.

@paulyg
Created January 15, 2011 00:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulyg/780574 to your computer and use it in GitHub Desktop.
Save paulyg/780574 to your computer and use it in GitHub Desktop.
A test for PHP bug 53755, FILTER_SANITIZE_STRING truncates strings with unmatched "<" character
--TEST--
bug XXXXX FILTER_SANITIZE_STRING truncates string with single < in it.
--SKIPIF--
<?php if (!extension_loaded("filter")) die("skip"); ?>
--FILE--
<?php
echo filter_var('four is < 6', FILTER_SANITIZE_STRING);
echo "\n";
echo filter_var("four is < 6 <script>alert('XSS');</script> yes it is", FILTER_SANITIZE_STRING);
echo "\n";
echo filter_var("four is < 6 < script >alert('XSS');< /script > yes it is", FILTER_SANITIZE_STRING);
echo "\n";
?>
--EXPECT--
four is < 6
four is < 6 alert(&#39;XSS&#39;); yes it is
four is < 6 < script >alert(&#39;XSS&#39;);< /script > yes it is
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment