Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions ext/dom/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions ext/dom/inner_outer_html_mixin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down