From d5abcc44b3e9e607a8ab466d991f45cb2dc9bb94 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 18 Apr 2007 02:45:47 +0000 Subject: [PATCH] Fix detection of bad elements. --- CHANGES | 4 +++- doc/reference.html | 12 ++++++------ doc/relnotes.html | 5 ++++- mxml-file.c | 12 +++++++++++- mxml.xml | 6 +++--- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 54e5a72..22fab45 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/doc/reference.html b/doc/reference.html index 9df16f0..b6e59aa 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -70,9 +70,9 @@
  • mxmlNewReal()
  • mxmlNewText()
  • mxmlNewTextf()
  • -
  • mxmlRelease()  Mini-XML 2.4 
  • +
  • mxmlRelease()  Mini-XML 2.3 
  • mxmlRemove()
  • -
  • mxmlRetain()  Mini-XML 2.4 
  • +
  • mxmlRetain()  Mini-XML 2.3 
  • mxmlSaveAllocString()
  • mxmlSaveFd()
  • mxmlSaveFile()
  • @@ -87,7 +87,7 @@
  • mxmlSetReal()
  • mxmlSetText()
  • mxmlSetTextf()
  • -
  • mxmlSetWrapMargin()  Mini-XML 2.4 
  • +
  • mxmlSetWrapMargin()  Mini-XML 2.3 
  • mxmlWalkNext()
  • mxmlWalkPrev()
  • @@ -715,7 +715,7 @@ mxmlNewTextf(

    Returns

    New node

    -

     Mini-XML 2.4 mxmlRelease()

    +

     Mini-XML 2.3 mxmlRelease()

    Description

    Release a node. @@ -759,7 +759,7 @@ mxmlRemove(

    Returns

    Nothing.

    -

     Mini-XML 2.4 mxmlRetain()

    +

     Mini-XML 2.3 mxmlRetain()

    Description

    Retain a node. @@ -1118,7 +1118,7 @@ mxmlSetTextf(

    Returns

    0 on success, -1 on failure

    -

     Mini-XML 2.4 mxmlSetWrapMargin()

    +

     Mini-XML 2.3 mxmlSetWrapMargin()

    Description

    Set the the wrap margin when saving XML data. diff --git a/doc/relnotes.html b/doc/relnotes.html index 54e4398..00ff35e 100644 --- a/doc/relnotes.html +++ b/doc/relnotes.html @@ -10,8 +10,11 @@

  • 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.
  • diff --git a/mxml-file.c b/mxml-file.c index 004c5e7..9db7ffb 100644 --- a/mxml-file.c +++ b/mxml-file.c @@ -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; diff --git a/mxml.xml b/mxml.xml index 8ca8e55..ed2b65a 100644 --- a/mxml.xml +++ b/mxml.xml @@ -499,7 +499,7 @@ string must be nul-terminated and is formatted into the new node. When the reference count reaches zero, the node (and any children) is deleted via mxmlDelete(). -@since Mini-XML 2.4@ +@since Mini-XML 2.3@ mxml_node_t * Node @@ -522,7 +522,7 @@ This function does nothing if the node has no parent. Retain a node. -@since Mini-XML 2.4@ +@since Mini-XML 2.3@ mxml_node_t * Node @@ -798,7 +798,7 @@ The node is not changed if it is not a text node. Wrapping is disabled when "column" is <= 0. -@since Mini-XML 2.4@ +@since Mini-XML 2.3@ int Column for wrapping