Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0RC3

Bug #2029 encodeXml / decodeXmlEntities not reciprocals
Submitted: 2004-07-31 00:01 UTC
From: collectours at free dot fr Assigned:
Status: Suspended Package: XML_Tree
PHP Version: 4.3.8 OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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 !
Your email address:
MUST BE VALID
Solve the problem : 50 - 31 = ?

 
 [2004-07-31 00:01 UTC] collectours at free dot fr
Description: ------------ XML_Tree Node.php,v 1.22 2004/05/26 15:03:25 A string passed through XML_Tree_Node::encodeXmlEntities, and then through XML_Tree_Node::decodeXmlEntities is not anymore like the original 1 - the single quotes ' remains as entity apos; 2 - the ^ remains as #94 (ampersand and semicolon intentionnaly ommited in the report) Reproduce code: --------------- <?php require_once('XML/Tree/Node.php'); $str = "bla ' bla^"; $encoded = XML_Tree_Node::encodeXmlEntities($str); $decoded = XML_Tree_Node::decodeXmlEntities($encoded); header('Content-type:text/plain'); print "before:$str\n"; print "after: $decoded\n"; ?> Expected result: ---------------- Should be before:bla ' bla^ after: bla ' bla^ ---------------------- 1) The get_html_translation_table(HTML_ENTITIES) (with or without ENT_QUOTES) renders the single quote as #39, not apos; so it is not translated back 2) the \^ is missing in the preg_replace line 538 Actual result: -------------- before:bla ' bla^ after: bla &apos; bla^ Fix proposal (tested): 1) in encodeXmlEntities line 538 ...\+\,\@_\^])/e" 2) in decodeXmlEntities $trans_tbl = array_flip($trans_tbl); // add the apos not given by trans table $trans_tbl['&apos;'] = "'";

Comments

 [2006-10-01 19:52 UTC] arnaud (Arnaud Limbourg)
Until the package gets a new maintainer.