Eina: Fix issue in the XML parser when a tag was in a comment or a CDATA.

SVN revision: 71518
This commit is contained in:
Vincent Torri 2012-05-29 22:00:29 +00:00
parent 4889dc71d2
commit 96bfc84a12
4 changed files with 37 additions and 14 deletions

View File

@ -290,4 +290,6 @@
* remove --disable-posix-threads and --disable-win32-threads
from configure options, and detect automatically the threading
support.
Fix bug in the XML parser when a tag was in a comment or a
cdata

View File

@ -14,6 +14,7 @@ Fixes:
and PPC).
* Portability issue with Eina_Value test suite when unsigned where not promoted to
unsigned long (case on Itanium).
* Fix issue in the XML parser when a tag was in a comment or a CDATA.
Eina 1.2.0

View File

@ -159,6 +159,28 @@ _eina_simple_xml_tag_end_find(const char *itr, const char *itr_end)
return NULL;
}
static inline const char *
_eina_simple_xml_tag_comment_end_find(const char *itr, const char *itr_end)
{
for (; itr < itr_end; itr++)
if ((*itr == '-') &&
((itr + 1 < itr_end) && (*(itr + 1) == '-')) &&
((itr + 2 < itr_end) && (*(itr + 2) == '>')))
return itr + 2;
return NULL;
}
static inline const char *
_eina_simple_xml_tag_cdata_end_find(const char *itr, const char *itr_end)
{
for (; itr < itr_end; itr++)
if ((*itr == ']') &&
((itr + 1 < itr_end) && (*(itr + 1) == ']')) &&
((itr + 2 < itr_end) && (*(itr + 2) == '>')))
return itr + 2;
return NULL;
}
/**
* @endcond
*/
@ -342,21 +364,17 @@ eina_simple_xml_parse(const char *buf, unsigned buflen, Eina_Bool strip, Eina_Si
toff = 0;
}
p = _eina_simple_xml_tag_end_find(itr + 1 + toff, itr_end);
if (p)
{
if (type == EINA_SIMPLE_XML_CDATA)
{
/* must end with ]]> */
while ((p) && (memcmp(p - 2, "]]>", 3)))
p = _eina_simple_xml_tag_end_find(p + 1, itr_end);
}
if (type == EINA_SIMPLE_XML_CDATA)
p = _eina_simple_xml_tag_cdata_end_find(itr + 1 + toff, itr_end);
else if (type == EINA_SIMPLE_XML_COMMENT)
p = _eina_simple_xml_tag_comment_end_find(itr + 1 + toff, itr_end);
else
p = _eina_simple_xml_tag_end_find(itr + 1 + toff, itr_end);
if ((p) && (*p == '<'))
{
type = EINA_SIMPLE_XML_ERROR;
toff = 0;
}
if ((p) && (*p == '<'))
{
type = EINA_SIMPLE_XML_ERROR;
toff = 0;
}
if (p)

View File

@ -21,4 +21,6 @@
<trkpt lon="5.62314" lat="53.010303"/>
</trkseg>
</trk>
<!-- <foo>bar</foo> -->
<![CDATA[ <foo>bar</foo> ]]>
</gpx>