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

Bug #5016 preceeding zeroes truncated in string
Submitted: 2005-08-05 18:51 UTC
From: frymaster at linuxmail dot org Assigned: alan_k
Status: Closed Package: XML_Wddx
PHP Version: 4.3.9 OS: Linux Centos 4.0
Roadmaps: (Not assigned)    
Subscription  


 [2005-08-05 18:51 UTC] frymaster at linuxmail dot org
Description: ------------ in xml_wddx 1.0.1: a string of numbers with a preceeding zero, ie. "0677", is automatically converted to type "number" at serialization, thus eliminating the zero. the code that explicitly casts strings of digits to numbers is located on line 102 and reads: if ( is_numeric ($value) && (intval(0+$value) == $value) ) return "<number>$value</number>"; this bug occurrs even if the string of digits is explicitly cast as a string prior to serialization. grant horwood Test script: --------------- require_once "XML/Wddx.php"; $wddx_parser = new XML_Wddx(); $test_array = array((string)"098", (string)"0098", "0098R"); print_r($test_array); $some_wddx = $wddx_parser->serialize($test_array); print_r($some_wddx); $back_test_array = $wddx_parser->deserialize($some_wddx); print_r($back_test_array); Expected result: ---------------- Array ( [0] => 098 [1] => 0098 [2] => 0098R ) <wddxPacket version='1.0'><header/><data> <array length='3'> <string>098</string> <string>0098</string> <string>0098R</string> </array> </data></wddxPacket> Array ( [0] => 098 [1] => 0098 [2] => 0098R ) Actual result: -------------- Array ( [0] => 098 [1] => 0098 [2] => 0098R ) <wddxPacket version='1.0'><header/><data> <array length='3'> <number>098</number> <number>0098</number> <string>0098R</string> </array> </data></wddxPacket> Array ( [0] => 98 <- where are my zeroes? [1] => 98 [2] => 0098R )

Comments

 [2005-08-09 08:07 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!