php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62884 parse_ini_file() results changed in 5.3.15
Submitted: 2012-08-21 23:48 UTC Modified: 2012-11-16 23:52 UTC
From: fidian at rumkin dot com Assigned: pierrick (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3Git-2012-08-21 (Git) OS: Ubuntu Linus 12.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fidian at rumkin dot com
New email:
PHP Version: OS:

 

 [2012-08-21 23:48 UTC] fidian at rumkin dot com
Description:
------------
Given an INI file that looks like this

ini = "a"b"

and when you use parse_ini_file with INI_SCANNER_RAW, PHP used to return this as 
array('ini' => 'a"b') and now returns it as array('ini' => 'ab"').  This does 
not appear to match with Microsoft's GetPrivateProfileString 
(http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx) where they say 
that values which are quoted with either single or double quotes are simply 
unquoted.  My expected behavior would be to mirror the Microsoft parser, 
especially when in raw mode.

Note:  I am not talking about changing INI_SCANNER_NORMAL, just the raw mode so 
I can get the unparsed values.

According to git-bisect, commit 4e6f27f4db6121e67f17906b27cc829120738b71 is the 
culprit, but I suspect that the fix for bug 51094 is really to blame.

Test script:
---------------
<?php
error_reporting(0);
$result = parse_ini_string('ini = "a"b"', false, INI_SCANNER_RAW);
var_export($result);
echo "\n";


Expected result:
----------------
array (
  'ini' => 'a"b',
)


Actual result:
--------------
array (
  'ini' => 'ab"',
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-21 23:50 UTC] fidian at rumkin dot com
For clarification, what Microsoft says is

If the string associated with lpKeyName is enclosed in single or double 
quotation marks, the marks are discarded when the GetPrivateProfileString 
function retrieves the string.

This leads me to believe that it merely checks if the first and last character 
match and if they are a " or ' and then would remove both the first and last 
character.
 [2012-08-22 05:43 UTC] laruence@php.net
-Assigned To: +Assigned To: pierrick
 [2012-08-22 05:43 UTC] laruence@php.net
Pierrick,  do you have time to look into this?  thanks
 [2012-11-16 23:52 UTC] pierrick@php.net
The fix for this bug has been committed.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-11-16 23:52 UTC] pierrick@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 09:01:29 2024 UTC