#47306 [Opn->Bgs]: don't allow non-printable characters in constant names
| From: | johannes@php.net | Date: | Fri, 06 Feb 2009 22:40:31 +0000 |
| Subject: | #47306 [Opn->Bgs]: don't allow non-printable characters in constant names | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133588@lists.php.net to get a copy of this message | ||
ID: 47306
Updated by: johannes@php.net
Reported By: michael dot buergi at zhdk dot ch
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
PHP Version: 5.2.8
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You can atually use any characters as constant name and if you can't
trust your developers you have way bigger issues ...
Previous Comments:
------------------------------------------------------------------------
[2009-02-04 16:18:10] michael dot buergi at zhdk dot ch
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 this bug report at http://bugs.php.net/?id=47306&edit=1