Edit report at https://bugs.php.net/bug.php?id=65568&edit=1
ID: 65568
Comment by: kristo at waher dot net
Reported by: kristo at waher dot net
Summary: parse_ini_file() and INI_SCANNER_RAW breaks with
newlines
Status: Not a bug
Type: Bug
Package: Strings related
Operating System: Windows 7
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
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 http://en.wikipedia.org/wiki/INI_file
Previous Comments:
------------------------------------------------------------------------
[2013-08-28 20:08:32] [email protected]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
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
this:
name=thomas
moore
age=42
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
clear
name="thomas
moore"
age=42
------------------------------------------------------------------------
[2013-08-28 06:29:23] kristo at waher dot net
Description:
------------
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:
---------------
INI:
name="thomas
moore";
SCRIPT:
parse_ini_file('test.ini',false,INI_SCANNER_RAW);
Expected result:
----------------
no error
Actual result:
--------------
Warning: syntax error, unexpected '"' in test.ini on line 2
in \test.php on line 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65568&edit=1