Edit report at https://bugs.php.net/bug.php?id=63512&edit=1

 ID:                 63512
 Patch added by:     pierr...@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:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: 63512-v3.diff
Revision:   1352954789
URL:        
https://bugs.php.net/patch-display.php?bug=63512&patch=63512-v3.diff&revision=1352954789


Previous Comments:
------------------------------------------------------------------------
[2012-11-15 04:45:54] pierr...@php.net

I created a patch for this bug (which also fix #62884).

Could you make a quick code review before I commit it ? 

Thanks

------------------------------------------------------------------------
[2012-11-15 04:12:53] pierr...@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] larue...@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

Reply via email to