Bug #65568 [Opn->Nab]: parse_ini_file() and INI_SCANNER_RAW breaks with newlines
| From: | ab@php.net | Date: | Wed, 28 Aug 2013 20:08:32 +0000 |
| Subject: | Bug #65568 [Opn->Nab]: parse_ini_file() and INI_SCANNER_RAW breaks with newlines | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181274@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65568&edit=1
ID: 65568
Updated by: ab@php.net
Reported by: kristo at waher dot net
Summary: parse_ini_file() and INI_SCANNER_RAW breaks with
newlines
-Status: Open
+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:
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
Previous Comments:
------------------------------------------------------------------------
[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