Edit report at https://bugs.php.net/bug.php?id=51094&edit=1
ID: 51094 Updated by: pierr...@php.net Reported by: viaujoc at videotron dot ca Summary: parse_ini_file() with INI_SCANNER_RAW cuts a value that includes a semi-colon Status: Open Type: Bug Package: Filesystem function related PHP Version: * -Assigned To: +Assigned To: pierrick Block user comment: N Private report: N New Comment: I'll soon have one last look to make sure this patch doesn't introduce any problem before committing it. But if someone else want to review it, any comments will be welcome. Previous Comments: ------------------------------------------------------------------------ [2012-06-06 17:00:22] pierr...@php.net The following patch has been added/updated: Patch Name: bug51094.diff Revision: 1339002022 URL: https://bugs.php.net/patch-display.php?bug=51094&patch=bug51094.diff&revision=1339002022 ------------------------------------------------------------------------ [2011-09-25 10:27:16] paj...@php.net It is clearly a parsing error as the ; is part of a quoted string. It also works with php.ini so it may be possible to get that work with other ini as well (while the code is different...) ------------------------------------------------------------------------ [2010-02-20 20:00:14] viaujoc at videotron dot ca This change in the behavior of parse_ini_file() is not documented in either the documentation page for the function or the "Backward Incompatible Changes" from "Migrating from PHP 5.2.x to PHP 5.3.x". I also hope that the updated documentation promised in bug #47703 will be published soon. ------------------------------------------------------------------------ [2010-02-20 10:54:50] j...@php.net 1. There is no such thing as raw scanning in PHP 5.2 2. This is exactly how it's supposed to work. The ; is still comment even in the raw mode. All other chars are considered just chars. 3. In PHP 5.3 the backslash inside double quotes is considered escape char. No bug here either. Use single quotes instead. ------------------------------------------------------------------------ [2010-02-19 22:10:16] viaujoc at videotron dot ca Description: ------------ When using parse_ini_file() function with $scanner_mode=INI_SCANNER_RAW, any semi-colon (;) in the value is seen as the end of the value, even if it is enclosed in quotes. The behavior of parse_ini_file() in PHP 5.3 with either $scanner_mode at RAW or NORMAL cannot reproduce the behavior of PHP 5.2. Reproduce code: --------------- test.ini: [TheSection] MyKey="my;value\$" example.php: <?php var_dump(parse_ini_file("test.ini",true,INI_SCANNER_RAW)); ?> Expected result: ---------------- array(1) { ["TheSection"]=> array(1) { ["MyKey"]=> string(10) "my;value\$" } } Actual result: -------------- In PHP 5.2 (without the $scanner_mode parameter in parse_ini_file()): array(1) { ["TheSection"]=> array(1) { ["MyKey"]=> string(10) "my;value\$" } } (the value is returned exactly as it appears in test.ini) In PHP 5.3 (with $scanner_mode=INI_SCANNER_RAW): array(1) { ["TheSection"]=> array(1) { ["MyKey"]=> string(3) ""my" } } (notice that everything after the semi-colon has been truncated and the quote as the first character of the string) In PHP 5.3 (with $scanner_mode=INI_SCANNER_NORMAL): array(1) { ["TheSection"]=> array(1) { ["MyKey"]=> string(9) "my;value$" } } (notice the missing backslash (\) between the "e" and "$") ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=51094&edit=1