Fix detection of bad elements.

This commit is contained in:
Michael R Sweet 2007-04-18 02:45:47 +00:00
parent 40a4dd5242
commit d5abcc44b3
5 changed files with 27 additions and 12 deletions

View File

@ -5,8 +5,10 @@ CHANGES IN Mini-XML 2.3
- Added two exceptions to the LGPL to support static
linking of applications against Mini-XML.
- mxmlLoad*() did not detect missing > characters in
elements (STR #41)
- mxmlLoad*() did not detect missing close tags at the end
of an XML document.
of an XML document (STR #45)
- Added user_data and ref_count members to mxml_node_t
structure.
- Added mxmlReleaseNode() and mxmlRetainNode() APIs for

View File

@ -70,9 +70,9 @@
<li><a href='#mxmlNewReal'><tt>mxmlNewReal()</tt></a> </li>
<li><a href='#mxmlNewText'><tt>mxmlNewText()</tt></a> </li>
<li><a href='#mxmlNewTextf'><tt>mxmlNewTextf()</tt></a> </li>
<li><a href='#mxmlRelease'><tt>mxmlRelease()</tt></a> <span class='info'>&nbsp;Mini-XML 2.4&nbsp;</span></li>
<li><a href='#mxmlRelease'><tt>mxmlRelease()</tt></a> <span class='info'>&nbsp;Mini-XML 2.3&nbsp;</span></li>
<li><a href='#mxmlRemove'><tt>mxmlRemove()</tt></a> </li>
<li><a href='#mxmlRetain'><tt>mxmlRetain()</tt></a> <span class='info'>&nbsp;Mini-XML 2.4&nbsp;</span></li>
<li><a href='#mxmlRetain'><tt>mxmlRetain()</tt></a> <span class='info'>&nbsp;Mini-XML 2.3&nbsp;</span></li>
<li><a href='#mxmlSaveAllocString'><tt>mxmlSaveAllocString()</tt></a> </li>
<li><a href='#mxmlSaveFd'><tt>mxmlSaveFd()</tt></a> </li>
<li><a href='#mxmlSaveFile'><tt>mxmlSaveFile()</tt></a> </li>
@ -87,7 +87,7 @@
<li><a href='#mxmlSetReal'><tt>mxmlSetReal()</tt></a> </li>
<li><a href='#mxmlSetText'><tt>mxmlSetText()</tt></a> </li>
<li><a href='#mxmlSetTextf'><tt>mxmlSetTextf()</tt></a> </li>
<li><a href='#mxmlSetWrapMargin'><tt>mxmlSetWrapMargin()</tt></a> <span class='info'>&nbsp;Mini-XML 2.4&nbsp;</span></li>
<li><a href='#mxmlSetWrapMargin'><tt>mxmlSetWrapMargin()</tt></a> <span class='info'>&nbsp;Mini-XML 2.3&nbsp;</span></li>
<li><a href='#mxmlWalkNext'><tt>mxmlWalkNext()</tt></a> </li>
<li><a href='#mxmlWalkPrev'><tt>mxmlWalkPrev()</tt></a> </li>
</ul>
@ -715,7 +715,7 @@ mxmlNewTextf(
<h4>Returns</h4>
<p>New node</p>
<!-- NEW PAGE -->
<h3 class='title'><span class='info'>&nbsp;Mini-XML 2.4&nbsp;</span><a name='mxmlRelease'>mxmlRelease()</a></h3>
<h3 class='title'><span class='info'>&nbsp;Mini-XML 2.3&nbsp;</span><a name='mxmlRelease'>mxmlRelease()</a></h3>
<h4>Description</h4>
<p>Release a node.
@ -759,7 +759,7 @@ mxmlRemove(
<h4>Returns</h4>
<p>Nothing.</p>
<!-- NEW PAGE -->
<h3 class='title'><span class='info'>&nbsp;Mini-XML 2.4&nbsp;</span><a name='mxmlRetain'>mxmlRetain()</a></h3>
<h3 class='title'><span class='info'>&nbsp;Mini-XML 2.3&nbsp;</span><a name='mxmlRetain'>mxmlRetain()</a></h3>
<h4>Description</h4>
<p>Retain a node.
@ -1118,7 +1118,7 @@ mxmlSetTextf(
<h4>Returns</h4>
<p>0 on success, -1 on failure</p>
<!-- NEW PAGE -->
<h3 class='title'><span class='info'>&nbsp;Mini-XML 2.4&nbsp;</span><a name='mxmlSetWrapMargin'>mxmlSetWrapMargin()</a></h3>
<h3 class='title'><span class='info'>&nbsp;Mini-XML 2.3&nbsp;</span><a name='mxmlSetWrapMargin'>mxmlSetWrapMargin()</a></h3>
<h4>Description</h4>
<p>Set the the wrap margin when saving XML data.

View File

@ -10,8 +10,11 @@
<li>Added two exceptions to the LGPL to support static
linking of applications against Mini-XML.</li>
<li>mxmlLoad*() did not detect missing > characters in
elements (STR #41)</li>
<li>mxmlLoad*() did not detect missing close tags at the end
of an XML document.</li>
of an XML document (STR #45)</li>
<li>Added user_data and ref_count members to mxml_node_t
structure.</li>

View File

@ -1502,6 +1502,11 @@ mxml_load_data(mxml_node_t *top, /* I - Top node */
while ((ch = (*getc_cb)(p, &encoding)) != EOF)
if (isspace(ch) || ch == '>' || (ch == '/' && bufptr > buffer))
break;
else if (ch == '<')
{
mxml_error("Bare < in element!");
goto error;
}
else if (ch == '&')
{
if ((ch = mxml_get_entity(parent, p, &encoding, getc_cb)) == EOF)
@ -1966,11 +1971,16 @@ mxml_parse_element(mxml_node_t *node, /* I - Element node */
{
mxml_error("Expected '>' after '%c' for element %s, but got '%c'!",
ch, node->value.element.name, quote);
ch = EOF;
goto error;
}
break;
}
else if (ch == '<')
{
mxml_error("Bare < in element %s!", node->value.element.name);
goto error;
}
else if (ch == '>')
break;

View File

@ -499,7 +499,7 @@ string must be nul-terminated and is formatted into the new node.</description>
When the reference count reaches zero, the node (and any children)
is deleted via mxmlDelete().
@since Mini-XML 2.4@</description>
@since Mini-XML 2.3@</description>
<argument name="node" direction="I">
<type>mxml_node_t *</type>
<description>Node</description>
@ -522,7 +522,7 @@ This function does nothing if the node has no parent.</description>
</returnvalue>
<description>Retain a node.
@since Mini-XML 2.4@</description>
@since Mini-XML 2.3@</description>
<argument name="node" direction="I">
<type>mxml_node_t *</type>
<description>Node</description>
@ -798,7 +798,7 @@ The node is not changed if it is not a text node.</description>
Wrapping is disabled when &quot;column&quot; is &lt;= 0.
@since Mini-XML 2.4@</description>
@since Mini-XML 2.3@</description>
<argument name="column" direction="I">
<type>int</type>
<description>Column for wrapping</description>