From: Rob Richards Date: Wed, 6 Jan 2010 13:13:17 +0000 (+0000) Subject: fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) X-Git-Tag: php-5.2.13RC1~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a31c58003beb34930b936fc6ac3021b816ad2c01;p=php fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) add test --- diff --git a/NEWS b/NEWS index 9a027705d5..cf69354afe 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP NEWS - Fixed build of mysqli with MySQL 5.5.0-m2. (Andrey) +- Fixed bug #50661 (DOMDocument::loadXML does not allow UTF-16). (Rob) - Fixed bug #50657 (copy() with an empty (zero-byte) HTTP source succeeds but returns false). (Ilia) - Fixed bug #50636 (MySQLi_Result sets values before calling constructor). diff --git a/ext/dom/document.c b/ext/dom/document.c index d468643d0f..b730c28411 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1598,7 +1598,7 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p /* {{{ */ -static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int options TSRMLS_DC) { +static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int source_len, int options TSRMLS_DC) { xmlDocPtr ret; xmlParserCtxtPtr ctxt = NULL; dom_doc_propsptr doc_props; @@ -1634,7 +1634,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int optio } } else { - ctxt = xmlCreateDocParserCtxt(source); + ctxt = xmlCreateMemoryParserCtxt(source, source_len); } if (ctxt == NULL) { @@ -1737,7 +1737,7 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) { RETURN_FALSE; } - newdoc = dom_document_parser(id, mode, source, options TSRMLS_CC); + newdoc = dom_document_parser(id, mode, source, source_len, options TSRMLS_CC); if (!newdoc) RETURN_FALSE; diff --git a/ext/dom/tests/bug50661.phpt b/ext/dom/tests/bug50661.phpt new file mode 100644 index 0000000000..3760db9b4e --- /dev/null +++ b/ext/dom/tests/bug50661.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #50661 (DOMDocument::loadXML does not allow UTF-16). +--SKIPIF-- + +--FILE-- +loadXML($data); +echo $dom->saveXML(); + +?> +--EXPECT-- + +