From 5fbacbec06e07f8f6d91efeb6b394eb07aa71ddd Mon Sep 17 00:00:00 2001 From: "Lee Thomason (grinliz)" Date: Sat, 8 Sep 2012 21:40:53 -0700 Subject: [PATCH] fix name parsing to accept additional lead characters --- tinyxml2.cpp | 10 +++------- xmltest.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 86a76a9..87063d3 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -134,16 +134,12 @@ char* StrPair::ParseName( char* p ) return 0; } - if ( !XMLUtil::IsAlpha( *p ) ) { - return 0; - } - while( *p && ( XMLUtil::IsAlphaNum( (unsigned char) *p ) || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' )) + || *p == ':' + || (*p == '-' && p>start ) // can be in a name, but not lead it. + || (*p == '.' && p>start ) )) // can be in a name, but not lead it. { ++p; } diff --git a/xmltest.cpp b/xmltest.cpp index 5077c25..17642f5 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -940,6 +940,12 @@ int main( int /*argc*/, const char ** /*argv*/ ) XMLTest( "QueryBoolText", boolValue, true, false ); } + { + const char* xml = "<_sub/><:sub/>"; + XMLDocument doc; + doc.Parse( xml ); + XMLTest( "Non-alpha element lead letter parses.", doc.Error(), false ); + } // ----------- Performance tracking -------------- {