Skip to content

Commit 19d320e

Browse files
author
Jani Taskinen
committed
- Fixed bug #50340 (php.ini parser does not allow spaces in ini keys)
1 parent b2cc8c6 commit 19d320e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ PHP NEWS
2323
- Fixed memory leak in extension loading when an error occurs on Windows.
2424
(Pierre)
2525

26+
- Fixed bug #50340 (php.ini parser does not allow spaces in ini keys). (Jani)
2627
- Fixed bug #50285 (xmlrpc does not preserve keys in encoded indexed arrays).
2728
(Felipe)
2829
- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in

Zend/zend_ini_scanner.l

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ ZEND_API ts_rsrc_id ini_scanner_globals_id;
105105
ZEND_API zend_ini_scanner_globals ini_scanner_globals;
106106
#endif
107107

108+
/* Eat leading whitespace */
109+
#define EAT_LEADING_WHITESPACE() \
110+
while (yytext[0]) { \
111+
if (yytext[0] == ' ' || yytext[0] == '\t') { \
112+
SCNG(yy_text)++; \
113+
yyleng--; \
114+
} else { \
115+
break; \
116+
} \
117+
}
118+
108119
/* Eat trailing whitespace + extra char */
109120
#define EAT_TRAILING_WHITESPACE_EX(ch) \
110121
while (yyleng > 0 && ( \
@@ -326,7 +337,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
326337
TABS_AND_SPACES [ \t]
327338
WHITESPACE [ \t]+
328339
CONSTANT [a-zA-Z][a-zA-Z0-9_]*
329-
LABEL [^=\n\r\t ;|&$~(){}!"\[]+
340+
LABEL [^=\n\r\t;|&$~(){}!"\[]+
330341
TOKENS [:,.\[\]"'()|^&+-/*=%$!~<>?@{}]
331342
OPERATORS [&|~()!]
332343
DOLLAR_CURLY "${"
@@ -367,6 +378,9 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
367378
}
368379

369380
<INITIAL>{LABEL}"["{TABS_AND_SPACES}* { /* Start of option with offset */
381+
/* Eat leading whitespace */
382+
EAT_LEADING_WHITESPACE();
383+
370384
/* Eat trailing whitespace and [ */
371385
EAT_TRAILING_WHITESPACE_EX('[');
372386

@@ -387,6 +401,12 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
387401
}
388402

389403
<ST_VARNAME>{LABEL} { /* Variable name */
404+
/* Eat leading whitespace */
405+
EAT_LEADING_WHITESPACE();
406+
407+
/* Eat trailing whitespace */
408+
EAT_TRAILING_WHITESPACE();
409+
390410
RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
391411
}
392412

@@ -404,6 +424,12 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
404424
}
405425

406426
<INITIAL>{LABEL} { /* Get option name */
427+
/* Eat leading whitespace */
428+
EAT_LEADING_WHITESPACE();
429+
430+
/* Eat trailing whitespace */
431+
EAT_TRAILING_WHITESPACE();
432+
407433
RETURN_TOKEN(TC_LABEL, yytext, yyleng);
408434
}
409435

0 commit comments

Comments
 (0)