[php-src] Issue #11709: Line breaks in strings inside ini files result in an error when using INI_SCANNER_RAW with parse_ini_file or parse_ini_string

From: Date: Fri, 14 Jul 2023 22:28:13 +0000
Subject: [php-src] Issue #11709: Line breaks in strings inside ini files result in an error when using INI_SCANNER_RAW with parse_ini_file or parse_ini_string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244968@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11709
Author: bohwaz

### 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
<?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_


Thread (1 message)

  • bohwaz
« previous php.bugs (#244968) next »