libxml2 r3807 - in trunk: . include/libxml
- From: rrichard svn gnome org
- To: svn-commits-list gnome org
- Subject: libxml2 r3807 - in trunk: . include/libxml
- Date: Mon, 5 Jan 2009 17:28:51 +0000 (UTC)
Author: rrichard
Date: Mon Jan 5 17:28:50 2009
New Revision: 3807
URL: http://svn.gnome.org/viewvc/libxml2?rev=3807&view=rev
Log:
* include/libxml/parser.h parser.c: add XML_PARSE_OLDSAX parser
option to enable pre 2.7 SAX behavior.
Modified:
trunk/ChangeLog
trunk/include/libxml/parser.h
trunk/parser.c
Modified: trunk/include/libxml/parser.h
==============================================================================
--- trunk/include/libxml/parser.h (original)
+++ trunk/include/libxml/parser.h Mon Jan 5 17:28:50 2009
@@ -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
Modified: trunk/parser.c
==============================================================================
--- trunk/parser.c (original)
+++ trunk/parser.c Mon Jan 5 17:28:50 2009
@@ -7047,9 +7047,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
@@ -7063,6 +7065,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);
@@ -7135,6 +7140,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);
@@ -7231,11 +7237,13 @@
/*
* Predefined entites override any extra definition
*/
- ent = xmlGetPredefinedEntity(name);
- if (ent != NULL) {
- xmlFree(name);
- *str = ptr;
- return(ent);
+ if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+ ent = xmlGetPredefinedEntity(name);
+ if (ent != NULL) {
+ xmlFree(name);
+ *str = ptr;
+ return(ent);
+ }
}
/*
@@ -7250,6 +7258,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);
}
@@ -7318,6 +7328,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",
@@ -14211,6 +14222,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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]