Line breaks in strings inside ini files result in an error when using INI_SCANNER_RAW with parse_ini_file or parse_ini_string
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
I don't think there should be a difference in the parsing of string literals in INI files between INI_SCANNER_RAW and other scanner modes. "abcd" is parsed the same, it should be as consistant with "ab\ncd".
The following code:
<?php
$ini = <<<EOF
a=42
b="line 1
line 2"
EOF;
var_dump(parse_ini_string($ini, false, INI_SCANNER_NORMAL));
var_dump(parse_ini_string($ini, false, INI_SCANNER_TYPED));
var_dump(parse_ini_string($ini, false, INI_SCANNER_RAW));
Resulted in this output:
array(2) {
["a"]=>
string(2) "42"
["b"]=>
string(13) "line 1
line 2"
}
array(2) {
["a"]=>
int(42)
["b"]=>
string(13) "line 1
line 2"
}
Warning: syntax error, unexpected '"' in Unknown on line 3
in /in/RTv1g on line 11
bool(false)
But I expected this output instead:
array(2) {
["a"]=>
string(2) "42"
["b"]=>
string(13) "line 1
line 2"
}
array(2) {
["a"]=>
int(42)
["b"]=>
string(13) "line 1
line 2"
}
array(2) {
["a"]=>
string(2) "42"
["b"]=>
string(13) "line 1
line 2"
}
Demo: https://3v4l.org/RTv1g/rfc#vgit.master
PHP Version
all, including master
Operating System
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior with the supplied PHP heredoc and compare parse_ini_string using INI_SCANNER_NORMAL, INI_SCANNER_TYPED, and INI_SCANNER_RAW; then trace the INI parser entry points for parse_ini_file and parse_ini_string. Done means multiline quoted strings are accepted in RAW with the same value as in the other scanner modes, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100