From:             arjen at react dot com
Operating system: All
PHP version:      5.3.18
Package:          Filesystem function related
Bug Type:         Bug
Bug description:parse_ini_file() with INI_SCANNER_RAW removes quotes from value.

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 bug report at https://bugs.php.net/bug.php?id=63512&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63512&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63512&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63512&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63512&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63512&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63512&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63512&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63512&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63512&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63512&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63512&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63512&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63512&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63512&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63512&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63512&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63512&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63512&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63512&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63512&r=mysqlcfg

Reply via email to