Edit report at https://bugs.php.net/bug.php?id=51094&edit=1
ID: 51094
Updated by: pajoye@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: Bogus
+Status: Open
Type: Bug
Package: Filesystem function related
-Operating System: Win2003
+Operating System:
-PHP Version: 5.3.1
+PHP Version: *
Block user comment: N
Private report: N
New Comment:
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...)
Previous Comments:
------------------------------------------------------------------------
[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] jani@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