php.net |  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
Description:
------------
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);
xml_parser_free($parser);
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);



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

http://www.w3.org/TR/REC-xml/#AVNormalize

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] amt@php.net
Glad that works.

BTW, we only "Close" actual bugs. All others are marked 
"Bogus."
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 01:01:23 2020 UTC