From: gdataonline at gmail dot com Operating system: Windows 7 x64 PHP version: 5.4.13 Package: Unknown/Other Function Bug Type: Bug Bug description:strip_tags() clobbers non-tag entities
Description: ------------ strip_tags() will clobber all remaining input after encountering non-HTML tags, regardless if embedded in "allowable-tags". When strip_tags() encounters a "<" followed by *any non-whitespace*, it assumes it's an HTML tag, even if it couldn't legally be one. In the example below, even something as simple as a "<=" appearing in JavaScript is enough to trigger the behavior. For a full list of characters that strip_tags() clobbers on, see this example: http://ideone.com/BEPINI Test script: --------------- <?php // Example 1: Without <= $code = "<script>if (foo >= bar){ alert(0); }</script>"; var_dump(strip_tags($code)); var_dump(strip_tags($code, "<script>")); // Example 2: With <= $code = "<script>if (foo <= bar){ alert(0); }</script>"; var_dump(strip_tags($code)); var_dump(strip_tags($code, "<script>")); ?> Expected result: ---------------- string(28) "if (foo >= bar){ alert(0); }" string(45) "<script>if (foo >= bar){ alert(0); }</script>" string(28) "if (foo <= bar){ alert(0); }" string(45) "<script>if (foo <= bar){ alert(0); }</script>" Actual result: -------------- string(28) "if (foo >= bar){ alert(0); }" string(45) "<script>if (foo >= bar){ alert(0); }</script>" string(8) "if (foo " string(16) "<script>if (foo " -- Edit bug report at https://bugs.php.net/bug.php?id=64430&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64430&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64430&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64430&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64430&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64430&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64430&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64430&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64430&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64430&r=support Expected behavior: https://bugs.php.net/fix.php?id=64430&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64430&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64430&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64430&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64430&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64430&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64430&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64430&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64430&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64430&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64430&r=mysqlcfg