|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28318 Line feed characters removed
Submitted: 2004-05-07 19:29 UTC Modified: 2004-05-07 20:38 UTC
From: dev at glossword dot info Assigned:
Status: Not a bug Package: XML related
PHP Version: 4.3.6 OS: Windows XP
Private report: No CVE-ID: None
 [2004-05-07 19:29 UTC] dev at glossword dot info
Line feed characters has beed accidentally removed from a tag attributes.

Reproduce code:
$string = "<a title=\" 123 \n 456 \r\n 789 \">link</a>";
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
xml_parse_into_struct($parser, $string, $values, $tags);
print '<pre>';
print_r( $values );
print '</pre>';

Expected result:
I expect to keep all line feed characters in attributes.
Better if it could be possible add a special option 
for xml_parser, like 
xml_parser_set_option($parser, XML_OPTION_KEEP_LF, 1);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-07 19:45 UTC]
I believe this is the correct behavior according to the 
XML specification. See:

To preserve line feeds, you should either wrap your 
attribute values inside a CDATA section or use entities, 
like &#xA;.
 [2004-05-07 20:06 UTC] dev at glossword dot info
&#xA; works great. Thanks. Not a bug.
 [2004-05-07 20:38 UTC]
Glad that works.

BTW, we only "Close" actual bugs. All others are marked 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 08 22:05:53 2022 UTC