|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32581 Parser ignores newlines
Submitted: 2005-04-05 03:47 UTC Modified: 2005-04-05 08:08 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: acoster at gmail dot com Assigned:
Status: Wont fix Package: XML related
PHP Version: 4.3.10 OS: Linux 2.4.26-grsec
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: acoster at gmail dot com
New email:
PHP Version: OS:


 [2005-04-05 03:47 UTC] acoster at gmail dot com
When using a xml_parser, initialized with the function above, any newlines inside a cdata block (even when the node is enclosed in <![CDATA[]>) are ignored. The same function was tested with PHP 5, and it worked.

Reproduce code:
class Article_Parser {
    function Article_Parser($fname) {
        $this->xp = xml_parser_create();
        xml_parser_set_option($this->xp, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
        xml_set_element_handler($this->xp, 'openTag', 'closeTag');
        xml_parser_set_option($this->xp,XML_OPTION_SKIP_WHITE, 0);
        xml_set_character_data_handler($this->xp, 'cdataHandler');
        xml_set_object($this->xp, $this);

        $this->tree = array();
        $this->__stack = array();
        $this->__sptr  = -1;

        xml_parse($this->xp, file_get_contents($fname)) or die('Erro ao fazer parsing do arquivo!');

Expected result:
A parsed XML file with its newlines.

Actual result:
A parsed XML file, whose newlines were ignored.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-05 08:08 UTC]
In PHP 5 this extension uses libxml2. In PHP 4 it uses expat.
You might wanna try with external expat library. (add --with-expat-dir=/install/prefix to your configure line)
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Aug 12 16:01:25 2020 UTC