File libxml2-2.7.1-oldsax.patch of Package libxml2
--- include/libxml/parser.h
+++ include/libxml/parser.h
@@ -1096,7 +1096,8 @@
crash if you try to modify the tree) */
XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
- XML_PARSE_HUGE = 1<<19 /* relax any hardcoded limit from the parser */
+ XML_PARSE_HUGE = 1<<19, /* relax any hardcoded limit from the parser */
+ XML_PARSE_OLDSAX = 1<<20 /* parse using SAX2 interface from before 2.7.0 */
} xmlParserOption;
XMLPUBFUN void XMLCALL
--- parser.c
+++ parser.c
@@ -7041,9 +7041,11 @@
/*
* Predefined entites override any extra definition
*/
- ent = xmlGetPredefinedEntity(name);
- if (ent != NULL)
- return(ent);
+ if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+ ent = xmlGetPredefinedEntity(name);
+ if (ent != NULL)
+ return(ent);
+ }
/*
* Increate the number of entity references parsed
@@ -7057,6 +7059,9 @@
if (ctxt->sax != NULL) {
if (ctxt->sax->getEntity != NULL)
ent = ctxt->sax->getEntity(ctxt->userData, name);
+ if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
+ (ctxt->options & XML_PARSE_OLDSAX))
+ ent = xmlGetPredefinedEntity(name);
if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
(ctxt->userData==ctxt)) {
ent = xmlSAX2GetEntity(ctxt, name);
@@ -7129,6 +7134,7 @@
*/
else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
(ent != NULL) && (ent->content != NULL) &&
+ (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(xmlStrchr(ent->content, '<'))) {
xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
"'<' in entity '%s' is not allowed in attributes values\n", name);
@@ -7224,10 +7230,13 @@
/*
* Predefined entites override any extra definition
*/
- ent = xmlGetPredefinedEntity(name);
- if (ent != NULL) {
- *str = ptr;
- return(ent);
+ if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+ ent = xmlGetPredefinedEntity(name);
+ if (ent != NULL) {
+ xmlFree(name);
+ *str = ptr;
+ return(ent);
+ }
}
/*
@@ -7242,6 +7251,8 @@
if (ctxt->sax != NULL) {
if (ctxt->sax->getEntity != NULL)
ent = ctxt->sax->getEntity(ctxt->userData, name);
+ if ((ent == NULL) && (ctxt->options & XML_PARSE_OLDSAX))
+ ent = xmlGetPredefinedEntity(name);
if ((ent == NULL) && (ctxt->userData==ctxt)) {
ent = xmlSAX2GetEntity(ctxt, name);
}
@@ -7310,6 +7321,7 @@
*/
else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
(ent != NULL) && (ent->content != NULL) &&
+ (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(xmlStrchr(ent->content, '<'))) {
xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
"'<' in entity '%s' is not allowed in attributes values\n",
@@ -14203,6 +14215,10 @@
ctxt->options |= XML_PARSE_HUGE;
options -= XML_PARSE_HUGE;
}
+ if (options & XML_PARSE_OLDSAX) {
+ ctxt->options |= XML_PARSE_OLDSAX;
+ options -= XML_PARSE_OLDSAX;
+ }
ctxt->linenumbers = 1;
return (options);
}