mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
fixed another validity checking in external parsed entities raised by
* xmlreader.c python/tests/reader2.py: fixed another validity checking in external parsed entities raised by Stphane Bidoul and added a specific regression test. * python/tests/reader3.py: cleanup Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jan 1 15:42:54 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlreader.c python/tests/reader2.py: fixed another validity
|
||||||
|
checking in external parsed entities raised by St<53>phane Bidoul
|
||||||
|
and added a specific regression test.
|
||||||
|
* python/tests/reader3.py: cleanup
|
||||||
|
|
||||||
Tue Dec 31 15:44:02 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Tue Dec 31 15:44:02 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xmlreader.c python/tests/reader2.py: fixed a problem with
|
* xmlreader.c python/tests/reader2.py: fixed a problem with
|
||||||
|
@ -95,6 +95,58 @@ if err != "":
|
|||||||
print err
|
print err
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Another test for external entity parsing and validation
|
||||||
|
#
|
||||||
|
|
||||||
|
s = """<!DOCTYPE test [
|
||||||
|
<!ELEMENT test (x)>
|
||||||
|
<!ELEMENT x (#PCDATA)>
|
||||||
|
<!ENTITY e SYSTEM "tst.ent">
|
||||||
|
]>
|
||||||
|
<test>
|
||||||
|
&e;
|
||||||
|
</test>
|
||||||
|
"""
|
||||||
|
tst_ent = """<x>hello</x>"""
|
||||||
|
expect="""1 test
|
||||||
|
3 #text
|
||||||
|
1 x
|
||||||
|
3 #text
|
||||||
|
15 x
|
||||||
|
3 #text
|
||||||
|
15 test
|
||||||
|
"""
|
||||||
|
res=""
|
||||||
|
|
||||||
|
def myResolver(URL, ID, ctxt):
|
||||||
|
if URL == "tst.ent":
|
||||||
|
return(StringIO.StringIO(tst_ent))
|
||||||
|
return None
|
||||||
|
|
||||||
|
libxml2.setEntityLoader(myResolver)
|
||||||
|
|
||||||
|
input = libxml2.inputBuffer(StringIO.StringIO(s))
|
||||||
|
reader = input.newTextReader("test3")
|
||||||
|
reader.SetParserProp(libxml2.PARSER_LOADDTD,1)
|
||||||
|
reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1)
|
||||||
|
reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1)
|
||||||
|
reader.SetParserProp(libxml2.PARSER_VALIDATE,1)
|
||||||
|
while reader.Read() == 1:
|
||||||
|
res = res + "%s %s\n" % (reader.NodeType(),reader.Name())
|
||||||
|
|
||||||
|
if res != expect:
|
||||||
|
print "test3 failed: unexpected output"
|
||||||
|
print res
|
||||||
|
sys.exit(1)
|
||||||
|
if err != "":
|
||||||
|
print "test3 failed: validation error found"
|
||||||
|
print err
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# cleanup
|
||||||
|
#
|
||||||
del input
|
del input
|
||||||
del reader
|
del reader
|
||||||
|
|
||||||
|
@ -94,6 +94,9 @@ if ret != 0:
|
|||||||
print "test_noent: Error detecting the end"
|
print "test_noent: Error detecting the end"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# cleanup
|
||||||
|
#
|
||||||
del f
|
del f
|
||||||
del input
|
del input
|
||||||
del reader
|
del reader
|
||||||
|
13
xmlreader.c
13
xmlreader.c
@ -151,7 +151,8 @@ xmlTextReaderStartElement(void *ctx, const xmlChar *fullname,
|
|||||||
ctxt->myDoc, ctxt->node, fullname);
|
ctxt->myDoc, ctxt->node, fullname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader->state = XML_TEXTREADER_ELEMENT;
|
if (reader != NULL)
|
||||||
|
reader->state = XML_TEXTREADER_ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,10 +185,12 @@ xmlTextReaderEndElement(void *ctx, const xmlChar *fullname) {
|
|||||||
ctxt->myDoc, node, fullname);
|
ctxt->myDoc, node, fullname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader->state == XML_TEXTREADER_ELEMENT)
|
if (reader != NULL) {
|
||||||
reader->wasempty = 1;
|
if (reader->state == XML_TEXTREADER_ELEMENT)
|
||||||
else
|
reader->wasempty = 1;
|
||||||
reader->wasempty = 0;
|
else
|
||||||
|
reader->wasempty = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user