mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +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:
@@ -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>
|
||||
|
||||
* tree.c: set doc on last child tree in xmlAddChildList for
|
||||
|
||||
@@ -1096,7 +1096,8 @@ typedef enum {
|
||||
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
|
||||
|
||||
15
parser.c
15
parser.c
@@ -7047,9 +7047,11 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
|
||||
/*
|
||||
* Predefined entites override any extra definition
|
||||
*/
|
||||
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 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
|
||||
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 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
|
||||
*/
|
||||
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,12 +7237,14 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
|
||||
/*
|
||||
* Predefined entites override any extra definition
|
||||
*/
|
||||
if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
|
||||
ent = xmlGetPredefinedEntity(name);
|
||||
if (ent != NULL) {
|
||||
xmlFree(name);
|
||||
*str = ptr;
|
||||
return(ent);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Increate the number of entity references parsed
|
||||
@@ -7250,6 +7258,8 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
|
||||
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 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
|
||||
*/
|
||||
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 @@ xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encodi
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user