|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-14 11:53 UTC] 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"" } Patches63512-v3.diff (last revision 2012-11-15 04:46 UTC by pierrick@php.net)63512-v2.diff (last revision 2012-11-15 04:12 UTC by pierrick@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
With this patch, the old behaviour is restored. But the "eat leading and trailing quotes" does not make sense.. var_dump(parse_ini_string('waa = "string" CONSTANT "anotherString"', false, INI_SCANNER_RAW)); 5.3.18 (wrong): array(1) { ["waa"]=> string(29) "string CONSTANT anotherString" } with patch (behaviour like in versions < 5.3.15) array(1) { ["waa"]=> string(29) "string" CONSTANT "anotherString" } Now string appears to be the constant, and CONSTANT a quoted string.. expected/better: array(1) { ["waa"]=> string(29) ""string" CONSTANT "anotherString"" } So IHMO remove this whole trim quotes thingy.