#38657 [NEW]: WDDX does not work anymore

From: Date: Wed, 30 Aug 2006 12:32:34 +0000
Subject: #38657 [NEW]: WDDX does not work anymore
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101535@lists.php.net to get a copy of this message
From: tom at ideaweb dot de Operating system: Debian, OSX PHP version: 4.4.4 PHP Bug Type: WDDX related Bug description: WDDX does not work anymore Description: ------------ I have a small cms which works over year, but with the upgrade from php-4.4.2 on Debian Sarge to php-4.4.4 wddx does not work anymore. I go back to the old version and it works. I used the same configuration script for both php versions. The problem is, its not easy for me as an admin to find the right portion of code, but tried to reproduce this on my mac, not linux, because its a production machine. i got malformed wddx output with my show() method. on my linux machine the wddx output was empty. i hope it helps and i made no mistakes :) Reproduce code: --------------- <?php function ideacms_isutf8( $pString, $pComp = false ) {/*{{{*/ if( !$pComp ) { return preg_match( '%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $pString ); } //if( utf8_encode( utf8_decode( $pString ) ) == $pString ) { if( iconv( 'ISO-8859-1', 'UTF-8', iconv( 'UTF-8', 'ISO-8859-1', $pString ) ) == $pString ) { return true; } return false; }/*}}}*/ Class CMS_WDDX { var $name; var $packet; function CMS_WDDX( $pName ) {/*{{{*/ $this->name = $pName; $this->packet = wddx_packet_start( $pName ); }/*}}}*/ function setVar( $pName, $pValue, $pOrd = false ) {/*{{{*/ eval( "\$$pName = \$this->entities(\$pValue, \$pOrd);" ); wddx_add_vars( $this->packet, $pName ); }/*}}}*/ function show() {/*{{{*/ //var_dump( wddx_packet_end( $this->packet ) );exit; if( !$this->packet ) return false; return wddx_packet_end( $this->packet ); }/*}}}*/ function entities( $pString, $pOrd = false ) {/*{{{*/ if ( is_array( $pString ) ) { foreach( $pString as $key => $value ) { $pString[$key] = CMS_WDDX::entities( $pString[$key], $pOrd ); } } elseif ( is_string( $pString ) ) { if( strpos( phpversion(), '4' ) === 0 ) { if ( $pOrd === true ) { if ( ideacms_isutf8( $pString ) ) { if( $pTemp = @utf8_decode( $pString ) ) { $pString = $pTemp; } } $pString = CMS_WDDX::unentities( $pString ); $temp = htmlspecialchars( $pString, ENT_NOQUOTES ); $pString = ''; for( $i = 0; $i < strlen( $temp ); $i++ ) { $ord = ord($temp{$i}); if($ord >= 126){ $pString .= "&#".$ord.";"; } else { switch($ord){ case 34 : $pString .= '"'; break; case 39 : $pString .= "'"; break; case 92 : $pString .= "\\"; break; default : $pString .= $temp{$i}; } } } } } else { $pString = CMS_WDDX::convert( $pString ); //$pString = CMS_WDDX::unentities( $pString ); //$pString = htmlspecialchars( $pString, ENT_NOQUOTES ); } } return $pString; }/*}}}*/ function unentities( $pString ) {/*{{{*/ if ( is_array( $pString ) ) { foreach( $pString as $key => $value ) { $pString[$key] = CMS_WDDX::unentities( $pString[$key] ); } } elseif ( is_string( $pString ) ) { $pString = ideacms_unentities( $pString, ( isset( $GLOBALS['ideacms_template_init'] ) ? false : true ) ); } return $pString; }/*}}}*/ function convert( $pString ) {/*{{{*/ #return $pString; if ( is_array( $pString ) ) { foreach( $pString as $key => $value ) { $pString[$key] = CMS_WDDX::convert( $pString[$key] ); } } elseif ( is_string( $pString ) ) { if( !ideacms_isutf8( $pString ) ) { if( $pTemp = @utf8_encode( $pString ) ) { $pString = $pTemp; } } } return $pString; }/*}}}*/ function unconvert( $pString ) {/*{{{*/ return $pString; }/*}}}*/ } $w = new CMS_WDDX( 'test' ); $w->setVar( "test", "1234567890123456" ); echo "<pre>"; echo ( $w->show() ); echo "</pre>"; ?> Expected result: ---------------- <pre><wddxPacket version='1.0'><header><comment>test</comment></header><data><struct><var name='test'><string>1234567890123456</string></var></struct></data></wddxPacket></pre> Actual result: -------------- <pre><wddxPacket version='1.0'><header><comment>test</comment></header><data><struct><va<string>1234567890123456</string></var></struct></data></wddxPacket></pre> -- Edit bug report at http://bugs.php.net/?id=38657&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38657&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38657&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38657&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38657&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38657&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38657&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38657&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38657&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38657&r=support Expected behavior: http://bugs.php.net/fix.php?id=38657&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38657&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38657&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38657&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38657&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38657&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38657&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38657&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38657&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38657&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38657&r=mysqlcfg

« previous php.bugs (#101535) next »