dmitry          Wed Sep  5 10:18:24 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/soap/tests/bugs        bug42488.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/soap   php_encoding.c 
  Log:
  Fixed bug #42488 (SoapServer reports an encoding error and the error itself 
breaks).
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.928&r2=1.2027.2.547.2.929&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.928 php-src/NEWS:1.2027.2.547.2.929
--- php-src/NEWS:1.2027.2.547.2.928     Wed Sep  5 08:26:31 2007
+++ php-src/NEWS        Wed Sep  5 10:18:22 2007
@@ -22,6 +22,8 @@
   (Hannes)
 - Fixed bug #42468 (Write lock on file_get_contents fails when using a 
   compression stream). (Ilia)
+- Fixed bug #42488 (SoapServer reports an encoding error and the error itself
+  breaks). (Dmitry)
 - Fixed bug #42359 (xsd:list type not parsed). (Dmitry)
 - Fixed bug #42326 (SoapServer crash). (Dmitry)
 - Fixed bug #42086 (SoapServer return Procedure '' not present for WSIBasic
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.103.2.21.2.36&r2=1.103.2.21.2.37&diff_format=u
Index: php-src/ext/soap/php_encoding.c
diff -u php-src/ext/soap/php_encoding.c:1.103.2.21.2.36 
php-src/ext/soap/php_encoding.c:1.103.2.21.2.37
--- php-src/ext/soap/php_encoding.c:1.103.2.21.2.36     Fri Aug 31 08:07:27 2007
+++ php-src/ext/soap/php_encoding.c     Wed Sep  5 10:18:22 2007
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.c,v 1.103.2.21.2.36 2007/08/31 08:07:27 dmitry Exp $ */
+/* $Id: php_encoding.c,v 1.103.2.21.2.37 2007/09/05 10:18:22 dmitry Exp $ */
 
 #include <time.h>
 
@@ -864,13 +864,50 @@
                        efree(str);
                        str = estrdup((char*)xmlBufferContent(out));
                        new_len = n;
-               } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
-                       soap_error1(E_ERROR,  "Encoding: string '%s' is not a 
valid utf-8 string", str);
                }
                xmlBufferFree(out);
                xmlBufferFree(in);
-       } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
-               soap_error1(E_ERROR,  "Encoding: string '%s' is not a valid 
utf-8 string", str);
+       }
+
+       if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
+               char *err = emalloc(new_len + 8);
+               char c;
+               int i;
+               
+               memcpy(err, str, new_len+1);
+               for (i = 0; (c = err[i++]);) {
+                       if ((c & 0x80) == 0) {
+                       } else if ((c & 0xe0) == 0xc0) {
+                               if ((err[i] & 0xc0) != 0x80) {
+                                       break;
+                               }
+                               i++;
+                       } else if ((c & 0xf0) == 0xe0) {
+                               if ((err[i] & 0xc0) != 0x80 || (err[i+1] & 
0xc0) != 0x80) {
+                                       break;
+                               }
+                               i += 2;
+                       } else if ((c & 0xf8) == 0xf0) {
+                               if ((err[i] & 0xc0) != 0x80 || (err[i+1] & 
0xc0) != 0x80 || (err[i+2] & 0xc0) != 0x80) {
+                                       break;
+                               }
+                               i += 3;
+                       } else {
+                               break;
+                       }
+               }
+               if (c) {
+                       err[i-1] = '\\';
+                       err[i++] = 'x';
+                       err[i++] = ((unsigned char)c >> 4) + ((((unsigned 
char)c >> 4) > 9) ? ('a' - 10) : '0');
+                       err[i++] = (c & 15) + (((c & 15) > 9) ? ('a' - 10) : 
'0');
+                       err[i++] = '.';
+                       err[i++] = '.';
+                       err[i++] = '.';
+                       err[i++] = 0;
+               }
+
+               soap_error1(E_ERROR,  "Encoding: string '%s' is not a valid 
utf-8 string", err);
        }
 
        text = xmlNewTextLen(BAD_CAST(str), new_len);

http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug42488.phpt?view=markup&rev=1.1
Index: php-src/ext/soap/tests/bugs/bug42488.phpt
+++ php-src/ext/soap/tests/bugs/bug42488.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to