diff --git a/ext/dom/document.c b/ext/dom/document.c index c56ec257cec31..4d366db08f0eb 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1432,24 +1432,28 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source, ctxt->sax->warning = php_libxml_ctx_warning; } - if (validate && ! (options & XML_PARSE_DTDVALID)) { + if (validate) { options |= XML_PARSE_DTDVALID; } - if (resolve_externals && ! (options & XML_PARSE_DTDATTR)) { + if (resolve_externals) { options |= XML_PARSE_DTDATTR; } - if (substitute_ent && ! (options & XML_PARSE_NOENT)) { + if (substitute_ent) { options |= XML_PARSE_NOENT; } - if (keep_blanks == 0 && ! (options & XML_PARSE_NOBLANKS)) { + if (keep_blanks == 0) { options |= XML_PARSE_NOBLANKS; } if (recover) { options |= XML_PARSE_RECOVER; } +#if LIBXML_VERSION >= 21300 + xmlCtxtSetOptions(ctxt, options); +#else php_libxml_sanitize_parse_ctxt_options(ctxt); xmlCtxtUseOptions(ctxt, options); +#endif if (recover) { old_error_reporting = EG(error_reporting); @@ -2086,10 +2090,16 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ ctxt->sax->error = php_libxml_ctx_error; ctxt->sax->warning = php_libxml_ctx_warning; } +#if LIBXML_VERSION >= 21400 + if (options) { + htmlCtxtSetOptions(ctxt, (int)options); + } +#else php_libxml_sanitize_parse_ctxt_options(ctxt); if (options) { htmlCtxtUseOptions(ctxt, (int)options); } +#endif htmlParseDocument(ctxt); xmlDocPtr newdoc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); diff --git a/ext/dom/inner_outer_html_mixin.c b/ext/dom/inner_outer_html_mixin.c index eee525cc47a6e..85124d41689af 100644 --- a/ext/dom/inner_outer_html_mixin.c +++ b/ext/dom/inner_outer_html_mixin.c @@ -291,8 +291,12 @@ static xmlNodePtr dom_xml_fragment_parsing_algorithm(dom_object *obj, const xmlN } parser->dict = context_node->doc->dict; +#if LIBXML_VERSION >= 21300 + xmlCtxtSetOptions(parser, XML_PARSE_IGNORE_ENC | XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NO_XXE); +#else php_libxml_sanitize_parse_ctxt_options(parser); xmlCtxtUseOptions(parser, XML_PARSE_IGNORE_ENC | XML_PARSE_NOERROR | XML_PARSE_NOWARNING); +#endif xmlCharEncodingHandlerPtr encoding = xmlFindCharEncodingHandler("UTF-8"); (void) xmlSwitchToEncoding(parser, encoding);