From: michael dot buergi at zhdk dot ch Operating system: PHP version: 5.2.8 PHP Bug Type: Feature/Change Request Bug description: don't allow non-printable characters in constant names
Description: ------------ current situation: Since PHP allows the characters 0x7f through 0xff in constant names, you can create constant names that contain non-printable characters - like the non-breaking space (NBSP) chr(160)! Sadly, any PHP-IDE (p.e. the Zend Studio for Eclipse) or editor that I have checked with recognises NBSP as whitespace. So this seems to be a perfect way to sabotage someones code. Just replace an ordinary space with NBSP and you are screwed. I pasted a small php script into "reproduce code" that defines a constant and echoes it two times, as it seems. But since there is a NBSP in front of the constant's name, PHP just echoes " SOME_CONST". the second echo is completely ignored since it searches for the constant "echo SOME_CONST". Motivation: Look at the sample script in a PHP editor and you won't find any error. Only in case you have E_NOTICE reporting turned on (which I don't) you would eventually find the mistake. change request: Having non-printable characters in constant names seems to be a bad idea for me. therefore I request that not the whole 0x7f-0xff character range could be used in constant names, but just the sane ones. And since I'm already here, why not raise the error-level from "notice" to "warning" if a constant's name is not found? You could introduce a php.ini flag that controls this behaviour. Thank you very much and kind regards Michael Reproduce code: --------------- <?php error_reporting(E_ALL); define('SOME_CONST', 'foobar'); echo SOME_CONST; echo SOME_CONST; ?> Expected result: ---------------- foobarfoobar Actual result: -------------- SOME_CONST -- Edit bug report at http://bugs.php.net/?id=47306&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47306&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47306&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47306&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47306&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47306&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47306&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47306&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47306&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47306&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47306&r=support Expected behavior: http://bugs.php.net/fix.php?id=47306&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47306&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47306&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47306&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47306&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47306&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47306&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47306&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47306&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47306&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47306&r=mysqlcfg