diff options
| author | Dmitry Stogov <dmitry@php.net> | 2004-09-07 14:34:46 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2004-09-07 14:34:46 +0000 |
| commit | 7e53511ec810c2ab257b9cb68c1fc315e057a37f (patch) | |
| tree | 6d02949a492f1ebdbc33ecac9bd5ff152630f5a6 /ext | |
| parent | 882a4c4d2c2f9960e7239e2a9afcd96a4b7a0c8d (diff) | |
| download | php-git-7e53511ec810c2ab257b9cb68c1fc315e057a37f.tar.gz | |
Make ext/soap work around libxml2 bug in xmlCheckUTF8 (2.6.7-2.6.13)
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/soap/php_encoding.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 9978612868..d107d7ff5d 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -581,6 +581,32 @@ static zval *to_zval_stringb(encodeTypePtr type, xmlNodePtr data) return ret; } +static int php_soap_xmlCheckUTF8(const unsigned char *s) +{ + int i; + unsigned char c; + + for (i = 0; (c = s[i++]);) { + if ((c & 0x80) == 0) { + } else if ((c & 0xe0) == 0xc0) { + if ((s[i++] & 0xc0) != 0x80) { + return 0; + } + } else if ((c & 0xf0) == 0xe0) { + if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) { + return 0; + } + } else if ((c & 0xf8) == 0xf0) { + if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) { + return 0; + } + } else { + return 0; + } + } + return 1; +} + static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNodePtr parent) { xmlNodePtr ret; @@ -612,12 +638,12 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo efree(str); str = estrdup(xmlBufferContent(out)); new_len = n; - } else if (!xmlCheckUTF8(str)) { + } else if (!php_soap_xmlCheckUTF8(str)) { soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str); } xmlBufferFree(out); xmlBufferFree(in); - } else if (!xmlCheckUTF8(str)) { + } else if (!php_soap_xmlCheckUTF8(str)) { soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str); } |
