|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65568 parse_ini_file() and INI_SCANNER_RAW breaks with newlines
Submitted: 2013-08-28 06:29 UTC Modified: 2013-08-28 20:08 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: kristo at waher dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.5.3 OS: Windows 7
Private report: No CVE-ID:
 [2013-08-28 06:29 UTC] kristo at waher dot net
parse_ini_file() works correctly if INI_SCANNER_RAW is not used. However once it 
is used then newlines throw errors in code and make it impossible to store any 
newline-including strings in INI files.

It's said that if you want to use newlines in your INI, you must enclose in 
double-quotes. This is true, but not if you use INI_SCANNER_RAW option.

Since the alternative of not using INI_SCANNER_RAW is not an option (due to how it 
converts some strings and values), this is a bug and should be fixed.

Test script:


Expected result:
no error

Actual result:
Warning: syntax error, unexpected '"' in test.ini on line 2
 in \test.php on line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-28 20:08 UTC]
-Status: Open +Status: Not a bug
 [2013-08-28 20:08 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

What's exactly the issue you can't use it without INI_SCANNER_RAW? With it the parser 
has no chance to recognize where the value ends, except each value is per line. Consider 


Should it give an error at the line 2 already or should it consider the line 3 as the 
continuation of the 'name' item value? Same logic as CSV. Without INI_SCANNER_RAW it's 

 [2013-08-29 06:57 UTC] kristo at waher dot net
INI_SCANNER_RAW should still allow newlines to be used in the INI. It says that if 
INI_SCANNER_RAW is set, then 'option values will not be parsed'. But a new line is 
not an option value if it is part of a value. This is similar to bug #51094 where 
the semicolon broke INI parsing, if INI_SCANNER_RAW was used.

A new line is an ACCEPTED PART OF INI VALUE according to documentation. 
INI_SCANNER_RAW should not break this. It should either support a direct new line 
or at least the escaped one. More at
 [2014-09-27 17:30 UTC] wxiaoguang at gmail dot com
I agree that this is a bug.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 06:01:32 2015 UTC