-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix GH-20871: Improve error message for invalid -d options #20899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
10591c9
2dd463f
617edaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,7 +205,11 @@ static ZEND_COLD void ini_error(const char *msg) | |
| error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */ | ||
| error_buf = (char *) emalloc(error_buf_len); | ||
|
|
||
| sprintf(error_buf, "%s in %s on line %" PRIu32 "\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno()); | ||
| if (strcmp(currently_parsed_filename, "Unknown") == 0 && CG(ini_parser_unbuffered_errors)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this check
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can |
||
| sprintf(error_buf, "%s in INI command line parameter '-d'\n", msg); | ||
| } else { | ||
| sprintf(error_buf, "%s in %s on line %" PRIu32 "\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno()); | ||
| } | ||
| } else { | ||
| error_buf = estrdup("Invalid configuration directive\n"); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --TEST-- | ||
| GH-20871: Bad error line and file for invalid "-d" arguments | ||
| --SKIPIF-- | ||
| <?php include "skipif.inc"; ?> | ||
| --FILE-- | ||
| <?php | ||
| $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED'); | ||
|
|
||
| exec("$php -d 'foo=bar=asd' -r \"echo 'hello' . PHP_EOL;\" 2>&1", $output, $exit_code); | ||
| print_r($output); | ||
|
|
||
| echo "\n"; | ||
|
|
||
| exec("$php -d 'foo=bar!asd' -r \"echo 'world' . PHP_EOL;\" 2>&1", $output2, $exit_code2); | ||
| print_r($output2); | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Array | ||
| ( | ||
| [0] => PHP: syntax error, unexpected '=' in INI command line parameter '-d' | ||
| [1] => hello | ||
| ) | ||
|
|
||
| Array | ||
| ( | ||
| [0] => PHP: syntax error, unexpected '!' in INI command line parameter '-d' | ||
| [1] => world | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to check
if (ini_filename)instead. Side-note: Theif (currently_parsed_filename) {is useless becausezend_ini_scanner_get_filename()never returnsNULL.