1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-27 12:15:34 +03:00

add XML_PARSE_OLDSAX parser option to enable pre 2.7 SAX behavior.

* include/libxml/parser.h parser.c: add XML_PARSE_OLDSAX parser 
  option to enable pre 2.7 SAX behavior.

svn path=/trunk/; revision=3807
This commit is contained in:
Rob Richards
2009-01-05 17:28:50 +00:00
parent 810a78b305
commit b9ed017d31
3 changed files with 30 additions and 9 deletions

View File

@@ -1,3 +1,8 @@
Mon Jan 05 18:28:41 CET 2009 Rob Richards <rrichards@cdatazone.org>
* include/libxml/parser.h parser.c: add XML_PARSE_OLDSAX parser
option to enable pre 2.7 SAX behavior.
Wed Dec 31 23:11:37 CET 2008 Rob Richards <rrichards@cdatazone.org> Wed Dec 31 23:11:37 CET 2008 Rob Richards <rrichards@cdatazone.org>
* tree.c: set doc on last child tree in xmlAddChildList for * tree.c: set doc on last child tree in xmlAddChildList for

View File

@@ -1096,7 +1096,8 @@ typedef enum {
crash if you try to modify the tree) */ crash if you try to modify the tree) */
XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */ 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_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; } xmlParserOption;
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL

View File

@@ -7047,9 +7047,11 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
/* /*
* Predefined entites override any extra definition * Predefined entites override any extra definition
*/ */
if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
ent = xmlGetPredefinedEntity(name); ent = xmlGetPredefinedEntity(name);
if (ent != NULL) if (ent != NULL)
return(ent); return(ent);
}
/* /*
* Increate the number of entity references parsed * Increate the number of entity references parsed
@@ -7063,6 +7065,9 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
if (ctxt->sax != NULL) { if (ctxt->sax != NULL) {
if (ctxt->sax->getEntity != NULL) if (ctxt->sax->getEntity != NULL)
ent = ctxt->sax->getEntity(ctxt->userData, name); 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) && if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
(ctxt->userData==ctxt)) { (ctxt->userData==ctxt)) {
ent = xmlSAX2GetEntity(ctxt, name); ent = xmlSAX2GetEntity(ctxt, name);
@@ -7135,6 +7140,7 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
*/ */
else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) && else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
(ent != NULL) && (ent->content != NULL) && (ent != NULL) && (ent->content != NULL) &&
(ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(xmlStrchr(ent->content, '<'))) { (xmlStrchr(ent->content, '<'))) {
xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
"'<' in entity '%s' is not allowed in attributes values\n", name); "'<' in entity '%s' is not allowed in attributes values\n", name);
@@ -7231,12 +7237,14 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
/* /*
* Predefined entites override any extra definition * Predefined entites override any extra definition
*/ */
if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
ent = xmlGetPredefinedEntity(name); ent = xmlGetPredefinedEntity(name);
if (ent != NULL) { if (ent != NULL) {
xmlFree(name); xmlFree(name);
*str = ptr; *str = ptr;
return(ent); return(ent);
} }
}
/* /*
* Increate the number of entity references parsed * Increate the number of entity references parsed
@@ -7250,6 +7258,8 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
if (ctxt->sax != NULL) { if (ctxt->sax != NULL) {
if (ctxt->sax->getEntity != NULL) if (ctxt->sax->getEntity != NULL)
ent = ctxt->sax->getEntity(ctxt->userData, name); ent = ctxt->sax->getEntity(ctxt->userData, name);
if ((ent == NULL) && (ctxt->options & XML_PARSE_OLDSAX))
ent = xmlGetPredefinedEntity(name);
if ((ent == NULL) && (ctxt->userData==ctxt)) { if ((ent == NULL) && (ctxt->userData==ctxt)) {
ent = xmlSAX2GetEntity(ctxt, name); ent = xmlSAX2GetEntity(ctxt, name);
} }
@@ -7318,6 +7328,7 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
*/ */
else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) && else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
(ent != NULL) && (ent->content != NULL) && (ent != NULL) && (ent->content != NULL) &&
(ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(xmlStrchr(ent->content, '<'))) { (xmlStrchr(ent->content, '<'))) {
xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
"'<' in entity '%s' is not allowed in attributes values\n", "'<' in entity '%s' is not allowed in attributes values\n",
@@ -14211,6 +14222,10 @@ xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encodi
ctxt->options |= XML_PARSE_HUGE; ctxt->options |= XML_PARSE_HUGE;
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; ctxt->linenumbers = 1;
return (options); return (options);
} }