]> granicus.if.org Git - php/commitdiff
Fixed bug #37569 (WDDX incorrectly encodes high-ascii characters)
authorIlia Alshanetsky <iliaa@php.net>
Thu, 25 May 2006 22:54:16 +0000 (22:54 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 25 May 2006 22:54:16 +0000 (22:54 +0000)
NEWS
ext/wddx/tests/bug37569.phpt [new file with mode: 0755]
ext/wddx/wddx.c

diff --git a/NEWS b/NEWS
index 171e210e25d150bb0ea2434632cc4d78a6a21148..a8460b9ba508545c24638e0b56d44d7b73a74c83 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,7 @@ PHP                                                                        NEWS
 - Added RFC2397 (data: stream) support. (Marcus)
 - Fixed handling of extremely long paths inside tempnam() function. (Ilia)
 - Fixed bug #37587 (var without attribute causes segfault). (Marcus)
+- Fixed bug #37569 (WDDX incorrectly encodes high-ascii characters). (Ilia)
 - Fixed bug #37565 (Using reflection::export with simplexml causing a crash).
   (Marcus)
 - Fixed bug #37563 (array_key_exists performance is poor for &$array). (Ilia)
diff --git a/ext/wddx/tests/bug37569.phpt b/ext/wddx/tests/bug37569.phpt
new file mode 100755 (executable)
index 0000000..f741d7b
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #37569 (WDDX incorrectly encodes high-ascii characters)
+--FILE--
+<?php
+echo wddx_serialize_value(chr(1))."\n";
+echo wddx_serialize_value(chr(128))."\n";
+?>
+--EXPECT--
+<wddxPacket version='1.0'><header/><data><string><char code='01'/></string></data></wddxPacket>
+<wddxPacket version='1.0'><header/><data><string><char code='80'/></string></data></wddxPacket>
index 76b136a63bbaef14c1f54267f0918ca6c76712c2..410f8378d8384359479450272beaace7e5e186d7 100644 (file)
@@ -399,9 +399,9 @@ static void php_wddx_serialize_string(wddx_packet *packet, zval *var)
                                        break;
 
                                default:
-                                       if (iscntrl((int)*(unsigned char *)p)) {
+                                       if (iscntrl((int)*(unsigned char *)p) || (int)*(unsigned char *)p >= 127) {
                                                FLUSH_BUF();
-                                               sprintf(control_buf, WDDX_CHAR, *p);
+                                               sprintf(control_buf, WDDX_CHAR, (int)*(unsigned char *)p);
                                                php_wddx_add_chunk(packet, control_buf);
                                        } else
                                                buf[l++] = *p;