fix name parsing to accept additional lead characters

This commit is contained in:
Lee Thomason (grinliz) 2012-09-08 21:40:53 -07:00
parent 4dbe869cd7
commit 5fbacbec06
2 changed files with 9 additions and 7 deletions

View File

@ -134,16 +134,12 @@ char* StrPair::ParseName( char* p )
return 0; return 0;
} }
if ( !XMLUtil::IsAlpha( *p ) ) {
return 0;
}
while( *p && ( while( *p && (
XMLUtil::IsAlphaNum( (unsigned char) *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 == '.' && p>start ) )) // can be in a name, but not lead it.
{ {
++p; ++p;
} }

View File

@ -940,6 +940,12 @@ int main( int /*argc*/, const char ** /*argv*/ )
XMLTest( "QueryBoolText", boolValue, true, false ); XMLTest( "QueryBoolText", boolValue, true, false );
} }
{
const char* xml = "<element><_sub/><:sub/><sub:sub/><sub-sub/></element>";
XMLDocument doc;
doc.Parse( xml );
XMLTest( "Non-alpha element lead letter parses.", doc.Error(), false );
}
// ----------- Performance tracking -------------- // ----------- Performance tracking --------------
{ {