1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

Vyacheslav Pindyura managed to trigger a bug in parseStartTag, fixing it.

* parser.c: Vyacheslav Pindyura managed to trigger a bug in
  parseStartTag, fixing it.
* test/att4 result/att4 result/noent/att4: adding the test
* xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added
  more methods to XmlTextReader.
Daniel
This commit is contained in:
Daniel Veillard 2002-12-16 22:04:11 +00:00
parent d453c6391a
commit 67df809c3a
9 changed files with 27946 additions and 7 deletions

View File

@ -1,3 +1,11 @@
Mon Dec 16 23:00:05 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c: Vyacheslav Pindyura managed to trigger a bug in
parseStartTag, fixing it.
* test/att4 result/att4 result/noent/att4: adding the test
* xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added
more methods to XmlTextReader.
Mon Dec 16 19:31:16 CET 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
* win32/libxml2.def.src: added more xml reader exports

View File

@ -1114,10 +1114,15 @@
<exports symbol='xmlTextReaderName'/>
<exports symbol='xmlTextReaderNamespaceUri'/>
<exports symbol='xmlTextReaderNodeType'/>
<exports symbol='xmlTextReaderNormalization'/>
<exports symbol='xmlTextReaderPrefix'/>
<exports symbol='xmlTextReaderPtr'/>
<exports symbol='xmlTextReaderQuoteChar'/>
<exports symbol='xmlTextReaderRead'/>
<exports symbol='xmlTextReaderReadInnerXml'/>
<exports symbol='xmlTextReaderReadOuterXml'/>
<exports symbol='xmlTextReaderReadState'/>
<exports symbol='xmlTextReaderReadString'/>
<exports symbol='xmlTextReaderValue'/>
<exports symbol='xmlTextReaderXmlLang'/>
</file>
@ -8002,6 +8007,11 @@ actually an xmlCharEncoding'/>
<return type='int' info='the xmlNodeType of the current node or -1 in case of error'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderNormalization' file='xmlreader'>
<info>The value indicating whether to normalize white space and attribute values. Since attribute value and end of line normalizations are a MUST in the XML specification only the value true is accepted. The broken bahaviour of accepting out of range character entities like &amp;#0; is of course not supported either.</info>
<return type='int' info='1 or -1 in case of error.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderPrefix' file='xmlreader'>
<info>A shorthand reference to the namespace associated with the node.</info>
<return type='xmlChar *' info='the prefix or NULL if not available'/>
@ -8017,6 +8027,26 @@ actually an xmlCharEncoding'/>
<return type='int' info='1 if the node was read successfully, 0 if there is no more nodes to read, or -1 in case of error'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderReadInnerXml' file='xmlreader'>
<info>Reads the contents of the current node, including child nodes and markup.</info>
<return type='xmlChar *' info='a string containing the XML content, or NULL if the current node is neither an element nor attribute, or has no child nodes. The string must be deallocated by the caller.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderReadOuterXml' file='xmlreader'>
<info>Reads the contents of the current node, including child nodes and markup.</info>
<return type='xmlChar *' info='a string containing the XML content, or NULL if the current node is neither an element nor attribute, or has no child nodes. The string must be deallocated by the caller.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderReadState' file='xmlreader'>
<info>Gets the read state of the reader.</info>
<return type='int' info='the state value, or -1 in case of error'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderReadString' file='xmlreader'>
<info>Reads the contents of an element or a text node as a string.</info>
<return type='xmlChar *' info='a string containing the contents of the Element or Text node, or NULL if the reader is positioned on any other type of node. The string must be deallocated by the caller.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderValue' file='xmlreader'>
<info>Provides the text value of the node if present</info>
<return type='xmlChar *' info='the string or NULL if not available. The retsult must be deallocated with xmlFree()'/>

View File

@ -30,6 +30,9 @@ void xmlFreeTextReader (xmlTextReaderPtr reader);
* Iterators
*/
int xmlTextReaderRead (xmlTextReaderPtr reader);
xmlChar * xmlTextReaderReadInnerXml (xmlTextReaderPtr reader);
xmlChar * xmlTextReaderReadOuterXml (xmlTextReaderPtr reader);
xmlChar * xmlTextReaderReadString (xmlTextReaderPtr reader);
/*
* Attributes of the node
@ -49,6 +52,7 @@ xmlChar * xmlTextReaderPrefix (xmlTextReaderPtr reader);
int xmlTextReaderQuoteChar (xmlTextReaderPtr reader);
xmlChar * xmlTextReaderValue (xmlTextReaderPtr reader);
xmlChar * xmlTextReaderXmlLang (xmlTextReaderPtr reader);
int xmlTextReaderReadState (xmlTextReaderPtr reader);
/*
* Methods of the XmlTextReader
@ -74,6 +78,7 @@ int xmlTextReaderMoveToAttributeNs (xmlTextReaderPtr reader,
int xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
int xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
int xmlTextReaderMoveToElement (xmlTextReaderPtr reader);
int xmlTextReaderNormalization (xmlTextReaderPtr reader);
#ifdef __cplusplus
}

View File

@ -6688,6 +6688,9 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
failed:
if (CUR == 0) {
GROW
}
if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
break;
if (!IS_BLANK(RAW)) {

View File

@ -586,9 +586,14 @@ Class xmlTextReader()
name()
namespaceUri()
nodeType()
normalization()
prefix()
quoteChar()
read()
readInnerXml()
readOuterXml()
readState()
readString()
value()
xmlLang()
Class xmlReg()

9264
result/att4 Normal file

File diff suppressed because it is too large Load Diff

9264
result/noent/att4 Normal file

File diff suppressed because it is too large Load Diff

9264
test/att4 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,10 @@
/*
* xmlreader.c: implements the xmlTextReader streaming node API
*
* NOTE:
* XmlTextReader.Normalization Property won't be supported, since
* it makes the parser non compliant to the XML recommendation
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
@ -52,9 +56,12 @@
#define XML_TEXTREADER_CTXT 2
typedef enum {
XML_TEXTREADER_MODE_NORMAL = 0,
XML_TEXTREADER_MODE_EOF = 1,
XML_TEXTREADER_MODE_CLOSED = 1
XML_TEXTREADER_MODE_INITIAL = 0,
XML_TEXTREADER_MODE_INTERACTIVE = 1,
XML_TEXTREADER_MODE_ERROR = 2,
XML_TEXTREADER_MODE_EOF =3,
XML_TEXTREADER_MODE_CLOSED = 4,
XML_TEXTREADER_MODE_READING = 5
} xmlTextReaderMode;
typedef enum {
@ -206,7 +213,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
* large CDATA sections
*/
if ((cur - reader->cur > 4096) && (reader->base == 0) &&
(reader->mode == XML_TEXTREADER_MODE_NORMAL)) {
(reader->mode == XML_TEXTREADER_MODE_INTERACTIVE)) {
cur = cur + 1;
val = xmlParseChunk(reader->ctxt,
(const char *) &inbuf->content[reader->cur],
@ -220,7 +227,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
/*
* Discard the consumed input when needed and possible
*/
if (reader->mode == XML_TEXTREADER_MODE_NORMAL) {
if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) {
if ((reader->cur >= 4096) && (reader->base == 0)) {
val = xmlBufferShrink(inbuf, cur);
if (val >= 0) {
@ -265,7 +272,8 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
fprintf(stderr, "\nREAD ");
DUMP_READER
#endif
if (reader->node == NULL) {
if (reader->mode == XML_TEXTREADER_MODE_INITIAL) {
reader->mode = XML_TEXTREADER_MODE_INTERACTIVE;
/*
* Initial state
*/
@ -365,6 +373,69 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
return(1);
}
/**
* xmlTextReaderReadState:
* @reader: the xmlTextReaderPtr used
*
* Gets the read state of the reader.
*
* Returns the state value, or -1 in case of error
*/
int
xmlTextReaderReadState(xmlTextReaderPtr reader) {
if (reader == NULL)
return(-1);
return(reader->mode);
}
/**
* xmlTextReaderReadInnerXml:
* @reader: the xmlTextReaderPtr used
*
* Reads the contents of the current node, including child nodes and markup.
*
* Returns a string containing the XML content, or NULL if the current node
* is neither an element nor attribute, or has no child nodes. The
* string must be deallocated by the caller.
*/
xmlChar *
xmlTextReaderReadInnerXml(xmlTextReaderPtr reader) {
TODO
return(NULL);
}
/**
* xmlTextReaderReadOuterXml:
* @reader: the xmlTextReaderPtr used
*
* Reads the contents of the current node, including child nodes and markup.
*
* Returns a string containing the XML content, or NULL if the current node
* is neither an element nor attribute, or has no child nodes. The
* string must be deallocated by the caller.
*/
xmlChar *
xmlTextReaderReadOuterXml(xmlTextReaderPtr reader) {
TODO
return(NULL);
}
/**
* xmlTextReaderReadString:
* @reader: the xmlTextReaderPtr used
*
* Reads the contents of an element or a text node as a string.
*
* Returns a string containing the contents of the Element or Text node,
* or NULL if the reader is positioned on any other type of node.
* The string must be deallocated by the caller.
*/
xmlChar *
xmlTextReaderReadString(xmlTextReaderPtr reader) {
TODO
return(NULL);
}
/************************************************************************
* *
* Constructor and destructors *
@ -406,7 +477,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input) {
ret->endElement = ret->sax->endElement;
ret->sax->endElement = xmlTextReaderEndElement;
ret->mode = XML_TEXTREADER_MODE_NORMAL;
ret->mode = XML_TEXTREADER_MODE_INITIAL;
ret->node = NULL;
ret->curnode = NULL;
val = xmlParserInputBufferRead(input, 4);
@ -1028,6 +1099,7 @@ int
xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
int ret;
xmlAttrPtr attr;
xmlNsPtr ns;
xmlNodePtr node;
if (reader == NULL)
@ -1051,6 +1123,11 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
ret++;
attr = attr->next;
}
ns = node->nsDef;
while (ns != NULL) {
ret++;
ns = ns->next;
}
return(ret);
}
@ -1493,3 +1570,22 @@ xmlTextReaderXmlLang(xmlTextReaderPtr reader) {
return(xmlNodeGetLang(reader->node));
}
/**
* xmlTextReaderNormalization:
* @reader: the xmlTextReaderPtr used
*
* The value indicating whether to normalize white space and attribute values.
* Since attribute value and end of line normalizations are a MUST in the XML
* specification only the value true is accepted. The broken bahaviour of
* accepting out of range character entities like &#0; is of course not
* supported either.
*
* Returns 1 or -1 in case of error.
*/
int
xmlTextReaderNormalization(xmlTextReaderPtr reader) {
if (reader == NULL)
return(-1);
return(1);
}