summaryrefslogtreecommitdiff
path: root/ext/soap/php_encoding.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-09-05 10:18:23 +0000
committerDmitry Stogov <dmitry@php.net>2007-09-05 10:18:23 +0000
commitee944bd1b5fa22f003805f760e63fa94fec0c487 (patch)
tree1c869cb0928a7d4f0fe80e3514b3fb52134e8277 /ext/soap/php_encoding.c
parent5d238efaa65ed24bfbec64fcb921e23ffbf55f52 (diff)
downloadphp-git-ee944bd1b5fa22f003805f760e63fa94fec0c487.tar.gz
Fixed bug #42488 (SoapServer reports an encoding error and the error itself breaks).
Diffstat (limited to 'ext/soap/php_encoding.c')
-rw-r--r--ext/soap/php_encoding.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 65e703d5d2..8354f87ace 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -864,13 +864,50 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
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);