|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51094 parse_ini_file() with INI_SCANNER_RAW cuts a value that includes a semi-colon
Submitted: 2010-02-19 22:10 UTC Modified: 2012-06-08 01:21 UTC
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: viaujoc at videotron dot ca Assigned: pierrick
Status: Closed Package: Filesystem function related
PHP Version: * OS:
Private report: No CVE-ID:
 [2010-02-19 22:10 UTC] viaujoc at videotron dot ca
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:


Expected result:
array(1) {
  array(1) {
    string(10) "my;value\$"

Actual result:
In PHP 5.2 (without the $scanner_mode parameter in parse_ini_file()):
array(1) {
  array(1) {
    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) {
  array(1) {
    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) {
  array(1) {
    string(9) "my;value$"
(notice the missing backslash (\) between the "e" and "$")


bug51094.diff (last revision 2012-06-07 13:32 UTC) by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-20 10:54 UTC]
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-20 20:00 UTC] 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.
 [2011-09-25 10:27 UTC]
-Status: Bogus +Status: Open -Operating System: Win2003 +Operating System: -PHP Version: 5.3.1 +PHP Version: *
 [2011-09-25 10:27 UTC]
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...)
 [2012-06-06 17:00 UTC]
The following patch has been added/updated:

Patch Name: bug51094.diff
Revision:   1339002022
 [2012-06-06 17:06 UTC]
-Assigned To: +Assigned To: pierrick
 [2012-06-06 17:06 UTC]
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.
 [2012-06-07 13:32 UTC]
The following patch has been added/updated:

Patch Name: bug51094.diff
Revision:   1339075946
 [2012-06-07 15:59 UTC]
Automatic comment on behalf of pierrick
Log: Fixed bug #51094 (parse_ini_file() with INI_SCANNER_RAW cuts a value that includes a semi-colon)
 [2012-06-07 16:24 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2012-06-07 16:24 UTC]
-Status: Assigned +Status: Closed
 [2012-06-07 22:05 UTC]
This fails for me with 5.4.5-dev on Windows 7.

The diff when I run it:
001+ string(4) ""ini"
002+ string(4) ""ini"
001- string(7) "ini;raw"
002- string(8) ""ini;raw"
 [2012-06-08 01:21 UTC]
This is strange, it's working well on my side. I'm on Linux but this kind of things should not change. Could you please verify that you have the last version of the 
Zend/zend_ini_scanner_defs.h and Zend/zend_ini_scanner.c files (they were committed just after the .l).

You could regenerate those files using this command : 
re2c --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l

to see if you have any differences

 [2012-06-08 18:37 UTC]
I think thats it.

The build where it was failing for me was r8779a9a, but it now passes on a build of the newer rd24d5b6.
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 21:01:55 2014 UTC