From:             grzegorz dot nosek at netart dot pl
Operating system: Linux
PHP version:      5.1.6
PHP Bug Type:     WDDX related
Bug description:  wddx mangles utf8 characters in serialized strings (broken 
more than in 4.4)

Description:
------------
wddx gets confused if you try to serialize a string with utf8 characters
(like the one below, it contains 'z with dot above', 'o acute', 'l stroke'
and 'w' - in case it gets messed up somehow).

serialized string will contain <char code='C5'/><char code='BC'/> ... etc,
which will get fed into xml_utf8_decode byte by byte (after decoding the
hex value), totally wrecking the output.

Up to this point, it's a duplicate of #38900.

However, PHP5 has another bug with variable names (e.g. hash keys)
containing UTF8 characters. It seems that the var name is converted down
from UTF8 to ISO-8859-1, yielding question marks instead of characters
outside latin1.

Another hackish patch (whitespace-mutilated):

--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -814,10 +814,7 @@ static void php_wddx_push_element(void *
if (atts) for (i = 0; atts[i]; i++) {
if (!strcmp(atts[i], EL_NAME) && atts[++i] && atts[i][0]) {
- char *decoded;
- int decoded_len;
- decoded = xml_utf8_decode(atts[i], strlen(atts[i]), &decoded_len,
"ISO-8859-1");
- stack->varname = decoded;
+ stack->varname = estrndup(atts[i], strlen(atts[i]));
break;
}
}
@@ -1057,7 +1054,12 @@ static void php_wddx_process_data(void *
wddx_stack_top(stack, (void**)&ent);
switch (Z_TYPE_P(ent)) {
case ST_STRING:
- decoded = xml_utf8_decode(s, len, &decoded_len, "ISO-8859-1");
+ if (len > 1) {
+ decoded = xml_utf8_decode(s, len, &decoded_len, "ISO-8859-1");
+ } else {
+ decoded = estrndup(s, len);
+ decoded_len = len;
+ }

Reproduce code:
---------------
See http://bugs.php.net/bug.php?id=38900


-- 
Edit bug report at http://bugs.php.net/?id=38901&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38901&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38901&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38901&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38901&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38901&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38901&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38901&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38901&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38901&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38901&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38901&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38901&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38901&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38901&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38901&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38901&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38901&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38901&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38901&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38901&r=mysqlcfg

Reply via email to