diff options
author | Pierrick Charron <pierrick@php.net> | 2012-11-16 18:04:14 -0500 |
---|---|---|
committer | Pierrick Charron <pierrick@php.net> | 2012-11-16 18:04:14 -0500 |
commit | 6dff07aa8c6fcf6cd84a2d1726ffcaeef74b9969 (patch) | |
tree | 0993e717a43000b419da3e55349c525b86a3f2da /Zend/zend_ini_scanner.l | |
parent | 7468fc0e374ad8cd8db482e6c228cdaae8aed075 (diff) | |
download | php-git-6dff07aa8c6fcf6cd84a2d1726ffcaeef74b9969.tar.gz |
Fixed bug #63512 parse_ini_file() with INI_SCANNER_RAW removes quotes from value
Restore the old behavior but keep bug 51094 fixed
Diffstat (limited to 'Zend/zend_ini_scanner.l')
-rw-r--r-- | Zend/zend_ini_scanner.l | 43 |
1 files changed, 25 insertions, 18 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); } |