DO NOT MERGE: Add validation for eternal enities

https://bugzilla.gnome.org/show_bug.cgi?id=780691

Bug: 36556310
Change-Id: I9450743e167c3c73af5e4071f3fc85e81d061648
(cherry picked from commit bef9af3d89d241bcb518c20cba6da2a2fd9ba049)

xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
 if (ctxt == NULL) return;
#ifdef LIBXML_SAX1_ENABLED
 if ((ctxt->sax) && (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
 ((ctxt->sax->startElementNs != NULL) ||
 (ctxt->sax->endElementNs != NULL))) ctxt->sax2 = 1;
#else
    ctxt->sax2 = 1;
#endif /* LIBXML_SAX1_ENABLED */

    ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
    ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
    ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
 if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
 (ctxt->str_xml_ns == NULL)) {
        xmlErrMemory(ctxt, NULL);
 }
}

xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
 if (ctxt == NULL) return;
#ifdef LIBXML_SAX1_ENABLED
 if ((ctxt->sax) && (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
 ((ctxt->sax->startElementNs != NULL) ||
 (ctxt->sax->endElementNs != NULL))) ctxt->sax2 = 1;
#else
    ctxt->sax2 = 1;
#endif /* LIBXML_SAX1_ENABLED */

    ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
    ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
    ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
 if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
 (ctxt->str_xml_ns == NULL)) {
        xmlErrMemory(ctxt, NULL);
 }
}
