#48830 [Opn->Bgs]: eval() parser error/warning on \'
| From: | jani@php.net | Date: | Tue, 07 Jul 2009 11:32:43 +0000 |
| Subject: | #48830 [Opn->Bgs]: eval() parser error/warning on \' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139380@lists.php.net to get a copy of this message | ||
ID: 48830
Updated by: jani@php.net
Reported By: s dot coletta at unidata dot it
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows/Ubuntu
PHP Version: 5.2.10
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
http://php.net/eval
Previous Comments:
------------------------------------------------------------------------
[2009-07-07 10:38:53] s dot coletta at unidata dot it
I'm sorry but if I write this code:
$str = "define('A','C:\\Dir\\');";
eval($str);
I expect to be evaluated properly because \\' has to be escaped to \'
So you are saying that: \\' is escaped to \' by the PHP parser when
assigned to the string $str then eval parses it again escaping \' a
second time and causing the error.
Now, if I need to eval a statement like that, and this is not
considered a bug, how can I workaround this?
------------------------------------------------------------------------
[2009-07-07 09:43:25] sjoerd-php at linuxonly dot nl
Thank you for your bug report.
The issue you report is not a bug. Both strings in your example look
like this:
define('A','C:\Dir\');
Note that the last single quote is escaped by the backslash. Passing
this to eval or putting this string in a PHP file will rightfully give a
parse error, because there is no ending quote.
------------------------------------------------------------------------
[2009-07-07 09:23:25] s dot coletta at unidata dot it
Description:
------------
Eval() makes a wrong parsing of a string ending with \\' or \'
The "Reproduce code" will not fail if you remove the ending \\ or \
like:
$str = "define('A','C:\\Dir');"; or
$str = "define('A','C:\Dir');";
Reproduce code:
---------------
$str = "define('A','C:\\Dir\\');";
eval($str);
or
$str = "define('A','C:\Dir\');";
eval($str);
Expected result:
----------------
No warnings or errors.
Just this statement executed:
define('A','C:\Dir\');
Actual result:
--------------
For both examples provided the result is the same:
Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
/test.php(3) : eval()'d code on line 1
Parse error: syntax error, unexpected ':' in /test.php(3) : eval()'d
code on line 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48830&edit=1