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 : 30 - 19 = ?

 
 [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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!