php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6804 parse_ini_file is not handling quoted strings properly
Submitted: 2000-09-18 21:02 UTC Modified: 2000-11-09 05:01 UTC
From: alex at zend dot com Assigned:
Status: Closed Package: PHP options/info functions
PHP Version: 4.0.2 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex at zend dot com
New email:
PHP Version: OS:

 

 [2000-09-18 21:02 UTC] alex at zend dot com
In the example below the gpc_order entry has the value "GPC" that should
be imported in the configuration hash as a 3 bytes long string. But it
is imported as 5 bytes with two zero bytes after the "GPC" characters. The patch to configuration-scanner.l is below the example.

<?
        $i = parse_ini_file("/usr/local/lib/php.ini");
        print(addslashes($i["gpc_order"]));
        print("\n");
?>

--- configuration-scanner.l     Mon Jun 26 21:15:49 2000
+++ /home/alex/develop/php-4.0.2.ok/main/configuration-scanner.l        Tue Sep 19 09:01:46 2000
@@ -107,21 +107,21 @@
 <INITIAL>["][^\n\r"]*["] {
        /* ENCAPSULATED TC_STRING */
 
        /* eat trailing " */
        yytext[yyleng-1]=0;
        
        /* eat leading " */
        yytext++;
 
        cfglval->value.str.val = zend_strndup(yytext,yyleng);
-       cfglval->value.str.len = yyleng;
+       cfglval->value.str.len = yyleng - 2;
        cfglval->type = IS_STRING;
        return TC_ENCAPSULATED_STRING;
 }
 
 <INITIAL>[&|~()!] {
        return yytext[0];
 }
 
 
 <INITIAL>[^=\n\r\t;|&~()!"]+ {

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-09 05:01 UTC] hholzgra@php.net
the new ini parser in zend_ini_parser.l gets it right ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC