Skip to content
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

Line breaks in strings inside ini files result in an error when using INI_SCANNER_RAW with parse_ini_file or parse_ini_string #11709

Open
bohwaz opened this issue Jul 14, 2023 · 0 comments

Comments

@bohwaz
Copy link
Contributor

bohwaz commented Jul 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant