Bug #63512 [Asn]: parse_ini_file() with INI_SCANNER_RAW removes quotes from value.
| From: | pierrick@php.net | Date: | Thu, 15 Nov 2012 04:45:54 +0000 |
| Subject: | Bug #63512 [Asn]: parse_ini_file() with INI_SCANNER_RAW removes quotes from value. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-174694@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63512&edit=1
ID: 63512
Updated by: pierrick@php.net
Reported by: arjen at react dot com
Summary: parse_ini_file() with INI_SCANNER_RAW removes quotes
from value.
Status: Assigned
Type: Bug
Package: Filesystem function related
Operating System: All
PHP Version: 5.3.18
-Assigned To: pierrick
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
I created a patch for this bug (which also fix #62884).
Could you make a quick code review before I commit it ?
Thanks
Previous Comments:
------------------------------------------------------------------------
[2012-11-15 04:12:53] pierrick@php.net
The following patch has been added/updated:
Patch Name: 63512-v2.diff
Revision: 1352952773
URL: https://bugs.php.net/patch-display.php?bug=63512&patch=63512-v2.diff&revision=1352952773
------------------------------------------------------------------------
[2012-11-14 15:19:00] laruence@php.net
pierrick, do you have time to look at this? thanks :)
------------------------------------------------------------------------
[2012-11-14 12:14:29] arjen at react dot com
Warning: expected result and actual result are swapped! :o
------------------------------------------------------------------------
[2012-11-14 11:53:41] arjen at react dot com
Description:
------------
An option value containing a constant followed by an quoted string is transformed
in constant string: CONSTANT "string" => CONSTANT string
This is broken since 5.3.15/5.4.5, probably by fixing
https://bugs.php.net/bug.php?id=51094
See http://3v4l.org/VkQgF
And INI_SCANNER_RAW isn't really raw, as quotes are removed anyway.
For value = "string" I would expect array('value' =>
'"string"') as result, so
one can differentiate between value = "CONSTANT" and value = CONSTANT.
Test script:
---------------
<?php
define('INSTALL_ROOT', "meukee!");
$array = parse_ini_string('
int = 123
constant = INSTALL_ROOT
quotedString = "string"
a = INSTALL_ROOT "waa"
b = "INSTALL_ROOT"
c = "waa" INSTALL_ROOT
d = INSTALL_ROOT "INSTALL_ROOT"', false, INI_SCANNER_RAW);
var_dump($array);
Expected result:
----------------
array(7) {
["int"]=>
string(3) "123"
["constant"]=>
string(12) "INSTALL_ROOT"
["quotedString"]=>
string(6) "string"
["a"]=>
string(16) "INSTALL_ROOT waa"
["b"]=>
string(12) "INSTALL_ROOT"
["c"]=>
string(16) "waa INSTALL_ROOT"
["d"]=>
string(25) "INSTALL_ROOT INSTALL_ROOT"
}
Actual result:
--------------
array(7) {
["int"]=>
string(3) "123"
["constant"]=>
string(12) "INSTALL_ROOT"
["quotedString"]=>
string(6) "string"
["a"]=>
string(18) "INSTALL_ROOT "waa""
["b"]=>
string(12) "INSTALL_ROOT"
["c"]=>
string(18) ""waa" INSTALL_ROOT"
["d"]=>
string(27) "INSTALL_ROOT "INSTALL_ROOT""
}
even better:
array(7) {
["int"]=>
string(3) "123"
["constant"]=>
string(12) "INSTALL_ROOT"
["quotedString"]=>
string(6) ""string""
["a"]=>
string(18) "INSTALL_ROOT "waa""
["b"]=>
string(12) "INSTALL_ROOT"
["c"]=>
string(18) ""waa" INSTALL_ROOT"
["d"]=>
string(27) "INSTALL_ROOT "INSTALL_ROOT""
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63512&edit=1