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

Bug #5187 Unserialize decodeFunction
Submitted: 2005-08-23 17:14 UTC
From: zik at zik dot hu Assigned: schst
Status: Closed Package: XML_Serializer
PHP Version: 5.0.4 OS: Debian Sarge
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 : 24 + 11 = ?

 
 [2005-08-23 17:14 UTC] zik at zik dot hu
Description: ------------ I think the decodeFunction option is not handled properly. At least I could not use it to work around missing target encodings of xml parser. (By having a small function that calls iconv() on input set as decodeFunction.) http://www.php.net/manual/en/function.xml-parser-set-option.php "Supported target encodings are ISO-8859-1, US-ASCII and UTF-8." Applying the attached patch solves this problem. NOTES: I don't know if this decodeFunction was intended for this or not, but this is how I need it. :) I also don't understand why the tag name is decoded and the value of attributes, but not the name of attributes. I don't believe attribute or tag names should be decoded. At least not for encoding conversion purposes. (It's not advisable to have xml tag and attr names in any other encoding than us-ascii, imho.) But if tag names are decoded then attribute names should be decoded as well. Test script: --------------- Unserializer-0.16.0_decode.patch: --- Unserializer.php.orig 2005-08-23 12:30:35.000000000 +0200 +++ Unserializer.php 2005-08-23 18:22:51.000000000 +0200 @@ -366,11 +366,12 @@ } else { $type = 'string'; } if ($this->options['decodeFunction'] !== null) { - $element = call_user_func($this->options['decodeFunction'], $element); + /* Do not decode element name */ + /* $element = call_user_func($this->options['decodeFunction'], $element); */ $attribs = array_map($this->options['decodeFunction'], $attribs); } $this->_depth++; $this->_dataStack[$this->_depth] = null; @@ -552,10 +553,15 @@ * @param string CDATA * @return void */ function cdataHandler($parser, $cdata) { + if ($this->options['decodeFunction'] !== null) { + /* Decode character data */ + $cdata = call_user_func( $this->options['decodeFunction'], $cdata ); + } + $this->_dataStack[$this->_depth] .= $cdata; } /** * create the XML_Parser instance

Comments

 [2005-09-22 14:19 UTC] schst
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.