facebook / facebook/hhvm

XML_OPTION_SKIP_WRITE doesn't properly handle whitespace out of xml tags

Open
#5,411 3 comments 0 reactions 0 assignees View on GitHub
php5 incompatibility
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

The example below produces an extra CDATA entry for the newline between the "test" and "desc" tags. This is on HHVM 3.7 and was caused by d737f8c99cba482a5e46527be04b3dff62a55969. This behavior is verified to differ in both php 5.4 and 5.5.

``` php

foo
bar

';
$parser = xml_parser_create();
$xml_values = [];
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $xml, $xml_values);
var_dump($xml_values);
```

```
devVM:~/scratch/newlinexml]$ php t.php
array(3) {
[0] =>
array(3) {
'tag' =>
string(4) "TEST"
'type' =>
string(4) "open"
'level' =>
int(1)
}
[1] =>
array(4) {
'tag' =>
string(4) "DESC"
'type' =>
string(8) "complete"
'level' =>
int(2)
'value' =>
string(9) "\nfoo\nbar\n"
}
[2] =>
array(3) {
'tag' =>
string(4) "TEST"
'type' =>
string(5) "close"
'level' =>
int(1)
}
}
devVM:~/scratch/newlinexml]$ hhvm t.php
array(4) {
[0]=>
array(4) {
["tag"]=>
string(4) "TEST"
["type"]=>
string(4) "open"
["level"]=>
int(1)
["value"]=>
string(1) "
"
}
[1]=>
array(4) {
["tag"]=>
string(4) "TEST"
["value"]=>
string(1) "
"
["type"]=>
string(5) "cdata"
["level"]=>
int(1)
}
[2]=>
array(4) {
["tag"]=>
string(4) "DESC"
["type"]=>
string(8) "complete"
["level"]=>
int(2)
["value"]=>
string(9) "
foo
bar
"
}
[3]=>
array(3) {
["tag"]=>
string(4) "TEST"
["type"]=>
string(5) "close"
["level"]=>
int(1)
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.