diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2018-09-15 17:08:58 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2018-09-15 17:08:58 +0200 |
commit | 6da3a1e3ce8726054f87f6cc63210bf4760c680d (patch) | |
tree | 6106d69fc735e12f6e381101de37e7b9803e5d23 /ext/standard | |
parent | 3f3e914df33793a36f51b4e44745d6a5aec4f685 (diff) | |
download | php-git-6da3a1e3ce8726054f87f6cc63210bf4760c680d.tar.gz |
Revert "Implement #67331: Have parse_ini_file add empty entries"
This reverts commit 3f3e914df33793a36f51b4e44745d6a5aec4f685.
The commit broke some tests on Windows, and generally needs more
though.
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/basic_functions.c | 11 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/bug49692.ini | 2 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/parse_ini_empty_values.phpt | 101 |
3 files changed, 11 insertions, 103 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 68f9014016..160e510831 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5976,6 +5976,10 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal switch (callback_type) { case ZEND_INI_PARSER_ENTRY: + if (!arg2) { + /* bare string - nothing to do */ + break; + } Z_TRY_ADDREF_P(arg2); zend_symtable_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), arg2); break; @@ -5984,6 +5988,11 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal { zval hash, *find_hash; + if (!arg2) { + /* bare string - nothing to do */ + break; + } + if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) { zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) { @@ -6024,7 +6033,7 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, zval *arg3, if (callback_type == ZEND_INI_PARSER_SECTION) { array_init(&BG(active_ini_file_section)); zend_symtable_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), &BG(active_ini_file_section)); - } else { + } else if (arg2) { zval *active_arr; if (Z_TYPE(BG(active_ini_file_section)) != IS_UNDEF) { diff --git a/ext/standard/tests/general_functions/bug49692.ini b/ext/standard/tests/general_functions/bug49692.ini index 8b839a6d6e..5def69a2bd 100644 --- a/ext/standard/tests/general_functions/bug49692.ini +++ b/ext/standard/tests/general_functions/bug49692.ini @@ -1,4 +1,4 @@ -;my.ini file +//my.ini file [sitemap] /home = default:index /info = default:info diff --git a/ext/standard/tests/general_functions/parse_ini_empty_values.phpt b/ext/standard/tests/general_functions/parse_ini_empty_values.phpt deleted file mode 100644 index 9569c46f01..0000000000 --- a/ext/standard/tests/general_functions/parse_ini_empty_values.phpt +++ /dev/null @@ -1,101 +0,0 @@ ---TEST-- -parse_ini_file(): empty values ---FILE-- -<?php - -$input = <<<EOD -; Comment starts with semi-colon(;) -; Section starts with [<section name>] - -; start of ini file - -[section] -foo=bar -bar= -quux[foo] -quux[] -quux[baz] -zzzz -EOD; - -var_dump(parse_ini_string($input, false, INI_SCANNER_NORMAL)); -var_dump(parse_ini_string($input, false, INI_SCANNER_RAW)); -var_dump(parse_ini_string($input, true, INI_SCANNER_NORMAL)); -var_dump(parse_ini_string($input, true, INI_SCANNER_RAW)); - -?> ---EXPECT-- -array(4) { - ["foo"]=> - string(3) "bar" - ["bar"]=> - string(0) "" - ["quux"]=> - array(3) { - ["foo"]=> - NULL - [0]=> - NULL - ["baz"]=> - NULL - } - ["zzzz"]=> - NULL -} -array(4) { - ["foo"]=> - string(3) "bar" - ["bar"]=> - string(0) "" - ["quux"]=> - array(3) { - ["foo"]=> - NULL - [0]=> - NULL - ["baz"]=> - NULL - } - ["zzzz"]=> - NULL -} -array(1) { - ["section"]=> - array(4) { - ["foo"]=> - string(3) "bar" - ["bar"]=> - string(0) "" - ["quux"]=> - array(3) { - ["foo"]=> - NULL - [0]=> - NULL - ["baz"]=> - NULL - } - ["zzzz"]=> - NULL - } -} -array(1) { - ["section"]=> - array(4) { - ["foo"]=> - string(3) "bar" - ["bar"]=> - string(0) "" - ["quux"]=> - array(3) { - ["foo"]=> - NULL - [0]=> - NULL - ["baz"]=> - NULL - } - ["zzzz"]=> - NULL - } -} |