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

Different behavior of the XML_OPTION_SKIP_WHITE option #4156

Closed
josepsanzcamp opened this issue Nov 6, 2014 · 4 comments
Closed

Different behavior of the XML_OPTION_SKIP_WHITE option #4156

josepsanzcamp opened this issue Nov 6, 2014 · 4 comments

Comments

@josepsanzcamp
Copy link

[sanz@localhost hhvm]$ php --version

PHP 5.6.2 (cli) (built: Oct 16 2014 08:36:16) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

[sanz@localhost hhvm]$ hhvm --version

HipHop VM 3.4.0-dev (rel)
Compiler: heads/master-0-g9a587ba04d6ac4924b6cc3445455452d12853944
Repo schema: 30fbdfaa3bba08f05de929a221f6d6b0078d82a8
Extension API: 20140829

[sanz@localhost hhvm]$ cat test3.php

<?php
function read_xml($skip_white) {
    $xml=file_get_contents("xml/test3.xml");
    $parser=xml_parser_create();
    xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
    xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,$skip_white);
    xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,"UTF-8");
    $array=array();
    $index=array();
    xml_parse_into_struct($parser,$xml,$array,$index);
    return $array;
}

function find_node($array,$node) {
    foreach($array as $key=>$val) {
        if($val["tag"]==$node) return $val;
    }
    return array();
}

// WITH XML_OPTION_SKIP_WHITE=0 WORKS FINE
$array=read_xml(0);
$node=find_node($array,"query");
print_r($node);

// WITH XML_OPTION_SKIP_WHITE=1 FAILS
$array=read_xml(1);
$node=find_node($array,"query");
print_r($node);
?>

[sanz@localhost hhvm]$ cat xml/test3.xml

<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <query>a
    b
    c
d
e
    f
    g
    h</query>
</root>

[sanz@localhost hhvm]$ php test3.php

Array
(
    [tag] => query
    [type] => complete
    [level] => 2
    [value] => a
    b
    c
d
e
    f
    g
    h
)
Array
(
    [tag] => query
    [type] => complete
    [level] => 2
    [value] => a
    b
    c
d
e
    f
    g
    h
)

[sanz@localhost hhvm]$ hhvm test3.php

Array
(
    [tag] => query
    [type] => complete
    [level] => 2
    [value] => a
    b
    c
d
e
    f
    g
    h
)
Array
(
    [tag] => query
    [type] => complete
    [level] => 2
    [value] => a    b   cde f   g   h
)
@hamidre13
Copy link
Contributor

I will look at it.

@josepsanzcamp
Copy link
Author

Thanks!!!

@josepsanzcamp
Copy link
Author

Hi hamidre13.

I have checked that the bug has been fixed. It's true???

Thanks in advance.

Josep.

@paulbiss
Copy link
Contributor

paulbiss commented Nov 9, 2014

Looks like it #4185. @hamidre13 for future reference if you put "Fixes #xxxx" in a line by itself in the summary it will close the issue for you.

@paulbiss paulbiss closed this as completed Nov 9, 2014
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

3 participants