summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierrick Charron <pierrick@php.net>2012-11-16 18:07:02 -0500
committerPierrick Charron <pierrick@php.net>2012-11-16 18:07:02 -0500
commit15ab75be8ad014c6fff5f2b908824ef18150a7ea (patch)
tree301449b60148ace270f323e8f4727b8d9a273feb
parent2a59f1d06c8d1ce64a7dc39f7736cc3499e0145d (diff)
parent6dff07aa8c6fcf6cd84a2d1726ffcaeef74b9969 (diff)
downloadphp-git-15ab75be8ad014c6fff5f2b908824ef18150a7ea.tar.gz
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Fixed bug #63512 parse_ini_file() with INI_SCANNER_RAW removes quotes from value
-rw-r--r--Zend/zend_ini_scanner.l43
-rw-r--r--ext/standard/tests/file/bug51094.phpt2
-rw-r--r--ext/standard/tests/file/bug63512.phpt33
3 files changed, 59 insertions, 19 deletions
diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l
index 8aeb076eab..2a21e77dd5 100644
--- a/Zend/zend_ini_scanner.l
+++ b/Zend/zend_ini_scanner.l
@@ -347,7 +347,7 @@ DOLLAR_CURLY "${"
SECTION_RAW_CHARS [^\]\n\r]
SINGLE_QUOTED_CHARS [^']
-RAW_VALUE_CHARS [^"\n\r;\000]
+RAW_VALUE_CHARS [^\n\r;\000]
LITERAL_DOLLAR ("$"([^{\000]|("\\"{ANY_CHAR})))
VALUE_CHARS ([^$= \t\n\r;&|~()!"'\000]|{LITERAL_DOLLAR})
@@ -445,33 +445,40 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
return '=';
}
-<ST_RAW>["] {
+<ST_RAW>{RAW_VALUE_CHARS} { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
+ char *sc = NULL;
while (YYCURSOR < YYLIMIT) {
- switch (*YYCURSOR++) {
+ switch (*YYCURSOR) {
case '\n':
- SCNG(lineno)++;
- break;
case '\r':
- if (*YYCURSOR != '\n') {
- SCNG(lineno)++;
- }
+ goto end_raw_value_chars;
break;
- case '"':
- yyleng = YYCURSOR - SCNG(yy_text) - 2;
- SCNG(yy_text)++;
- RETURN_TOKEN(TC_RAW, yytext, yyleng);
- case '\\':
- if (YYCURSOR < YYLIMIT) {
- YYCURSOR++;
+ case ';':
+ if (sc == NULL) {
+ sc = YYCURSOR;
}
+ /* no break */
+ default:
+ YYCURSOR++;
break;
}
}
+end_raw_value_chars:
yyleng = YYCURSOR - SCNG(yy_text);
- RETURN_TOKEN(TC_RAW, yytext, yyleng);
-}
-<ST_RAW>{RAW_VALUE_CHARS}+ { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
+ /* Eat trailing semicolons */
+ while (yytext[yyleng - 1] == ';') {
+ yyleng--;
+ }
+
+ /* Eat leading and trailing double quotes */
+ if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
+ SCNG(yy_text)++;
+ yyleng = yyleng - 2;
+ } else if (sc) {
+ YYCURSOR = sc;
+ yyleng = YYCURSOR - SCNG(yy_text);
+ }
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
diff --git a/ext/standard/tests/file/bug51094.phpt b/ext/standard/tests/file/bug51094.phpt
index 7823558722..f35dfb6d54 100644
--- a/ext/standard/tests/file/bug51094.phpt
+++ b/ext/standard/tests/file/bug51094.phpt
@@ -15,7 +15,7 @@ $ini = parse_ini_string("ini=\r\niniraw", null, INI_SCANNER_RAW);
var_dump($ini['ini']);
--EXPECTF--
string(7) "ini;raw"
-string(8) ""ini;raw"
+string(4) ""ini"
string(3) "ini"
string(7) "ini"raw"
string(0) ""
diff --git a/ext/standard/tests/file/bug63512.phpt b/ext/standard/tests/file/bug63512.phpt
new file mode 100644
index 0000000000..049db26588
--- /dev/null
+++ b/ext/standard/tests/file/bug63512.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Fixed bug #63512 (parse_ini_file() with INI_SCANNER_RAW removes quotes from value).
+--FILE--
+<?php
+
+$array = parse_ini_string('
+ int = 123
+ constant = INSTALL_ROOT
+ quotedString = "string"
+ a = INSTALL_ROOT "waa"
+ b = "INSTALL_ROOT"
+ c = "waa" INSTALL_ROOT
+ d = INSTALL_ROOT "INSTALL_ROOT"', false, INI_SCANNER_RAW);
+
+var_dump($array);
+--EXPECTF--
+array(7) {
+ ["int"]=>
+ string(3) "123"
+ ["constant"]=>
+ string(12) "INSTALL_ROOT"
+ ["quotedString"]=>
+ string(6) "string"
+ ["a"]=>
+ string(18) "INSTALL_ROOT "waa""
+ ["b"]=>
+ string(12) "INSTALL_ROOT"
+ ["c"]=>
+ string(18) ""waa" INSTALL_ROOT"
+ ["d"]=>
+ string(27) "INSTALL_ROOT "INSTALL_ROOT""
+}
+