php.net |  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
Votes:1
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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 - 16 = ?
Subscribe to this entry?

 
 [2005-04-05 03:47 UTC] acoster at gmail dot com
Description:
------------
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!');
        xml_parser_free($this->xp);
}


Expected result:
----------------
A parsed XML file with its newlines.

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-05 08:08 UTC] sniper@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC