minixml.c: now handle XML comments

This commit is contained in:
Thomas Bernard 2014-02-03 11:28:31 +01:00
parent 538c002373
commit b7a4f8d696
4 changed files with 36 additions and 6 deletions

View File

@ -1,6 +1,9 @@
$Id: Changelog.txt,v 1.191 2014/01/31 13:18:24 nanard Exp $ $Id: Changelog.txt,v 1.191 2014/01/31 13:18:24 nanard Exp $
miniUPnP client Changelog. miniUPnP client Changelog.
2014/02/03:
minixml now handle XML comments
VERSION 1.9 : released 2014/01/31 VERSION 1.9 : released 2014/01/31
2014/01/31: 2014/01/31:

View File

@ -1,10 +1,10 @@
/* $Id: minixml.c,v 1.9 2011/02/07 13:44:57 nanard Exp $ */ /* $Id: minixml.c,v 1.10 2012/03/05 19:42:47 nanard Exp $ */
/* minixml.c : the minimum size a xml parser can be ! */ /* minixml.c : the minimum size a xml parser can be ! */
/* Project : miniupnp /* Project : miniupnp
* webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* Author : Thomas Bernard * Author : Thomas Bernard
Copyright (c) 2005-2011, Thomas BERNARD Copyright (c) 2005-2014, Thomas BERNARD
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -113,7 +113,20 @@ static void parseelt(struct xmlparser * p)
const char * elementname; const char * elementname;
while(p->xml < (p->xmlend - 1)) while(p->xml < (p->xmlend - 1))
{ {
if((p->xml)[0]=='<' && (p->xml)[1]!='?') if((p->xml + 4) <= p->xmlend && (0 == memcmp(p->xml, "<!--", 4)))
{
p->xml += 3;
/* ignore comments */
do
{
p->xml++;
if ((p->xml + 3) >= p->xmlend)
return;
}
while(memcmp(p->xml, "-->", 3) != 0);
p->xml += 3;
}
else if((p->xml)[0]=='<' && (p->xml)[1]!='?')
{ {
i = 0; elementname = ++p->xml; i = 0; elementname = ++p->xml;
while( !IS_WHITE_SPACE(*p->xml) while( !IS_WHITE_SPACE(*p->xml)

View File

@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.348 2014/02/03 09:32:09 nanard Exp $
2014/02/03: 2014/02/03:
PCP : Add support for ANNOUNCE requests PCP : Add support for ANNOUNCE requests
minixml now handle XML comments
2013/12/16: 2013/12/16:
Attempt to compile with OS X/pf Attempt to compile with OS X/pf

View File

@ -1,10 +1,10 @@
/* $Id: minixml.c,v 1.9 2011/02/07 13:44:57 nanard Exp $ */ /* $Id: minixml.c,v 1.10 2012/03/05 19:42:47 nanard Exp $ */
/* minixml.c : the minimum size a xml parser can be ! */ /* minixml.c : the minimum size a xml parser can be ! */
/* Project : miniupnp /* Project : miniupnp
* webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* Author : Thomas Bernard * Author : Thomas Bernard
Copyright (c) 2005-2011, Thomas BERNARD Copyright (c) 2005-2014, Thomas BERNARD
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -113,7 +113,20 @@ static void parseelt(struct xmlparser * p)
const char * elementname; const char * elementname;
while(p->xml < (p->xmlend - 1)) while(p->xml < (p->xmlend - 1))
{ {
if((p->xml)[0]=='<' && (p->xml)[1]!='?') if((p->xml + 4) <= p->xmlend && (0 == memcmp(p->xml, "<!--", 4)))
{
p->xml += 3;
/* ignore comments */
do
{
p->xml++;
if ((p->xml + 3) >= p->xmlend)
return;
}
while(memcmp(p->xml, "-->", 3) != 0);
p->xml += 3;
}
else if((p->xml)[0]=='<' && (p->xml)[1]!='?')
{ {
i = 0; elementname = ++p->xml; i = 0; elementname = ++p->xml;
while( !IS_WHITE_SPACE(*p->xml) while( !IS_WHITE_SPACE(*p->xml)