summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2009-03-01 10:55:27 +0100
committerMike Hommey <glandium@debian.org>2009-03-01 10:55:27 +0100
commite248b20a3b7df364cc9617b8685b4c190338bcd2 (patch)
treef289c8584c4a44dd9cdb87003b193488da8b00f3 /parser.c
parent0c8f97ec9edb09da2e0b19c4f9ddf8c725cebc59 (diff)
downloadlibxml2-e248b20a3b7df364cc9617b8685b4c190338bcd2.tar.gz
Import upstream version 2.7.3upstream/2.7.3.dfsg
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/parser.c b/parser.c
index 4b7b758..9db664f 100644
--- a/parser.c
+++ b/parser.c
@@ -4142,6 +4142,9 @@ get_more:
line = ctxt->input->line;
col = ctxt->input->col;
}
+ /* something really bad happened in the SAX callback */
+ if (ctxt->instate != XML_PARSER_CONTENT)
+ return;
}
ctxt->input->cur = in;
if (*in == 0xD) {
@@ -4222,6 +4225,9 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
}
}
nbchar = 0;
+ /* something really bad happened in the SAX callback */
+ if (ctxt->instate != XML_PARSER_CONTENT)
+ return;
}
count++;
if (count > 50) {
@@ -7041,9 +7047,11 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
/*
* 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 +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);
@@ -7129,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);
@@ -7225,11 +7237,13 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
/*
* 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);
+ }
}
/*
@@ -7244,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);
}
@@ -7312,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",
@@ -14205,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);
}