php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65939 space before ";" breaks php.ini parsing
Submitted: 2013-10-21 15:00 UTC Modified: -
From: brainstorm at nopcode dot org Assigned:
Status: Closed Package: PHP options/info functions
PHP Version: 5.5.5 OS: irrelevant
Private report: No CVE-ID: None
 [2013-10-21 15:00 UTC] brainstorm at nopcode dot org
Description:
------------
The following php.ini snippet is found in the newest releases of php.ini (found un downloads section and Ubuntu 13.10):




; If disabled, all PHPDoc comments are dropped from the code to reduce the
 ;size of the optimized code.
;opcache.save_comments=1




The space before " ;size" breaks automation systems like Ansible which tries to parse it as a correctly formatted .ini file.

Test script:
---------------
Apparently it only breaks with builtin MacOSX Python distribution, so you would not be able to reproduce the above exception if running GNU/Linux or others.

#!/usr/bin/python

import ConfigParser, os

config = ConfigParser.ConfigParser()
config.readfp(open('php.ini'))
print config.get('PHP', 'max_execution_time')

Expected result:
----------------
It should return the value of the attribute instead of raising an exception:

$ python phpparse.py
30

Actual result:
--------------
TASK: [ini_file dest=/etc/php5/apache2/php.ini section=PHP option=max_execution_time value=200] ***
fatal: [86.50.168.69] => failed to parse: Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-1382344679.91-7968522912177/ini_file", line 1116, in <module>
    main()
  File "/root/.ansible/tmp/ansible-1382344679.91-7968522912177/ini_file", line 177, in main
    changed = do_ini(module, dest, section, option, value, state, backup)
  File "/root/.ansible/tmp/ansible-1382344679.91-7968522912177/ini_file", line 99, in do_ini
    cp.readfp(f)
  File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
    self._read(fp, filename)
  File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
    raise e
ConfigParser.ParsingError: File contains parsing errors: /etc/php5/apache2/php.ini
	[line 1859]: ' ;size of the optimized code.\n'

Patches

php.ini_configparser (last revision 2013-10-21 15:01 UTC by brainstorm at nopcode dot org)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-21 21:21 UTC] sixd@php.net
Automatic comment on behalf of sixd
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b6ceea4a25f667bfed6c26899dd55a274a3270d3
Log: Fixed bug #65939 (Space before &quot;;&quot; breaks php.ini parsing). (brainstorm at nopcode dot org)
 [2013-10-21 21:21 UTC] sixd@php.net
-Status: Open +Status: Closed
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of sixd
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b6ceea4a25f667bfed6c26899dd55a274a3270d3
Log: Fixed bug #65939 (Space before &quot;;&quot; breaks php.ini parsing). (brainstorm at nopcode dot org)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC