|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-30 12:34 UTC] tony2001@php.net
[2006-08-30 13:53 UTC] werner at esmt dot org
[2006-08-30 14:00 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 20:00:02 2025 UTC |
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>