#45384 [Ctl->Csd]: parse_ini_file will result in parse error with no trailing newline

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               45384
 Updated by:       [email protected]
 Reported By:      [email protected]
-Status:           Critical
+Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: Ubuntu
 PHP Version:      5.3CVS-2008-06-28 (CVS)
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2008-07-29 11:18:56] mats dot lindh at gmail dot com

The fix to #45372 did not fix this issue, the problem is still in both
the PHP5_3 and HEAD branches.

------------------------------------------------------------------------

[2008-06-29 00:50:26] [email protected]

$ echo -n "foo.bar = baz " > test.ini
20:46 alex@asonge:~
$ /opt/php53/bin/php -r 'var_dump(parse_ini_file("test.ini"));'
array(1) {
  ["foo.bar"]=>
  string(4) "baz "
}

so the answer is, yes, a trailing space does not cause the error...if
this needs to be marked as a duplicate, whatever it takes to get this
working the same as php<=5.2

------------------------------------------------------------------------

[2008-06-28 11:22:11] [email protected]

This is probably also related to the re2c/YYFILL() scanner issues I
described in Bug #45372.

I assume it's because a variable length rule is matching ("baz" in your
example) when it hits EOF and YYFILL() causes a return/abort. This
(unexpected $end) is more likely to happen with ini parsing, etc. where
it doesn't usually happen with VALID code in a PHP script because the
last thing matched in a typical file is with a fixed length rule (e.g.
"?>" or ";"), and these things only happen with variable length matches
as I explained in the other bug, though they shouldn't with working
scanner code, IMO.


BTW, does putting a space or something other than a newline after baz
allow it to work? Any character that's not allowed in the rule matching
baz should also make it "magically" work. :-)

------------------------------------------------------------------------

[2008-06-28 03:05:49] [email protected]

Description:
------------
an ini file with no trailing newline will result in "Parse error",
php5.3 only, 5.2 parses the file fine

Reproduce code:
---------------
$ echo -n "foo.bar = baz" > test.ini
$ /opt/php53/bin/php -r 'var_dump(parse_ini_file("test.ini"));'

Expected result:
----------------
array(1) {
  ["foo.bar"]=>
  string(3) "baz"
}


Actual result:
--------------
Warning: syntax error, unexpected $end in test.ini on line 1
 in Command line code on line 1

Call Stack:
    0.0003     312916   1. {main}() Command line code:0
    0.0128     312936   2. parse_ini_file() Command line code:1

array(0) {
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45384&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.