php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33240 XML_OPTION_SKIP_WHITE skips important spaces
Submitted: 2005-06-03 22:50 UTC Modified: 2005-06-08 02:37 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jacob at jacobweber dot com Assigned:
Status: Wont fix Package: XML related
PHP Version: 5.0.4 OS: Fedora Core 3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jacob at jacobweber dot com
New email:
PHP Version: OS:

 

 [2005-06-03 22:50 UTC] jacob at jacobweber dot com
Description:
------------
Turning on XML_OPTION_SKIP_WHITE causes the space in the following XML to be skipped:
<a>&apos; &amp;</a>

I believe this is incorrect. It doesn't skip the space in:
<a>&amp; &apos;</a>

Jacob

Reproduce code:
---------------
$xmlStr = "<a>&apos; &amp;</a>";
$xmlParser = xml_parser_create();
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($xmlParser, $xmlStr, $xmlArr);
xml_parser_free($xmlParser);
print_r($xmlArr);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [tag] => A
            [type] => complete
            [level] => 1
            [value] => ' &
        )

)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [tag] => A
            [type] => complete
            [level] => 1
            [value] => '&
        )

)

(note the missing space after the apostrophe

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-03 23:13 UTC] sniper@php.net
Yes, it skips whitespace when you set it to 1.
Otherwise it will not skip it, it's left as is.
 
I could not find the documentation for these options
(on the page for xml_parser_set_option()):

XML_OPTION_SKIP_WHITE
XML_OPTION_SKIP_TAGSTART

even as they seem to have existed since PHP 3? :)

 [2005-06-03 23:20 UTC] jacob at jacobweber dot com
I noticed that, so maybe they're not meant to be used. But one of the two examples I posted is incorrect: it should skip the space all the time or never.
 [2005-06-06 17:06 UTC] vrana@php.net
Options were added to the CVS docs but the problem remains. XML_OPTION_SKIP_WHITE skips almost nothing (e.g. <a> x x </a> is processed as " x x ").
 [2005-06-06 23:41 UTC] sniper@php.net
Perhaps you misunderstood how it works?
Why do you think it should skip ALL whitespace? (given the fact it never was documented to do that or anything else :)

 [2005-06-07 16:18 UTC] vrana@php.net
I see. XML_OPTION_SKIP_WHITE skips values that constist of whitespace characters only. I documented that but the original problem remains (&apos; &amp; should become ' &, not '&).
 [2005-06-08 02:37 UTC] sniper@php.net
I don't think we're suddenly gonna change it, even if the options haven't been never documented. (perhaps those should be removed even, since they don't seem to serve any purpose..)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 08:01:29 2024 UTC