mirror of https://github.com/AxioDL/tinyxml2.git
Fix attribute parsing to correctly handle white space
This commit is contained in:
parent
390e978da1
commit
78a773ddd9
|
@ -10,7 +10,7 @@ include(GNUInstallDirs)
|
||||||
################################
|
################################
|
||||||
# set lib version here
|
# set lib version here
|
||||||
|
|
||||||
set(GENERIC_LIB_VERSION "1.0.4")
|
set(GENERIC_LIB_VERSION "1.0.5")
|
||||||
set(GENERIC_LIB_SOVERSION "1")
|
set(GENERIC_LIB_SOVERSION "1")
|
||||||
|
|
||||||
|
|
||||||
|
|
2
dox
2
dox
|
@ -32,7 +32,7 @@ PROJECT_NAME = "TinyXML-2"
|
||||||
# This could be handy for archiving the generated documentation or
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 1.0.4
|
PROJECT_NUMBER = 1.0.5
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer
|
# for a project that appears at the top of each page and should give viewer
|
||||||
|
|
15
tinyxml2.cpp
15
tinyxml2.cpp
|
@ -914,13 +914,22 @@ bool XMLUnknown::Accept( XMLVisitor* visitor ) const
|
||||||
// --------- XMLAttribute ---------- //
|
// --------- XMLAttribute ---------- //
|
||||||
char* XMLAttribute::ParseDeep( char* p, bool processEntities )
|
char* XMLAttribute::ParseDeep( char* p, bool processEntities )
|
||||||
{
|
{
|
||||||
p = name.ParseText( p, "=", StrPair::ATTRIBUTE_NAME );
|
// Parse using the name rules: bug fix, was using ParseText before
|
||||||
|
p = name.ParseName( p );
|
||||||
if ( !p || !*p ) return 0;
|
if ( !p || !*p ) return 0;
|
||||||
|
|
||||||
|
// Skip white space before =
|
||||||
|
p = XMLUtil::SkipWhiteSpace( p );
|
||||||
|
if ( !p || *p != '=' ) return 0;
|
||||||
|
|
||||||
|
++p; // move up to opening quote
|
||||||
|
p = XMLUtil::SkipWhiteSpace( p );
|
||||||
|
if ( *p != '\"' && *p != '\'' ) return 0;
|
||||||
|
|
||||||
char endTag[2] = { *p, 0 };
|
char endTag[2] = { *p, 0 };
|
||||||
++p;
|
++p; // move past opening quote
|
||||||
|
|
||||||
p = value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES );
|
p = value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES );
|
||||||
//if ( value.Empty() ) return 0;
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ distribution.
|
||||||
|
|
||||||
static const int TIXML2_MAJOR_VERSION = 1;
|
static const int TIXML2_MAJOR_VERSION = 1;
|
||||||
static const int TIXML2_MINOR_VERSION = 0;
|
static const int TIXML2_MINOR_VERSION = 0;
|
||||||
static const int TIXML2_PATCH_VERSION = 4;
|
static const int TIXML2_PATCH_VERSION = 5;
|
||||||
|
|
||||||
namespace tinyxml2
|
namespace tinyxml2
|
||||||
{
|
{
|
||||||
|
@ -134,7 +134,7 @@ public:
|
||||||
void SetInternedStr( const char* str ) { Reset(); this->start = const_cast<char*>(str); }
|
void SetInternedStr( const char* str ) { Reset(); this->start = const_cast<char*>(str); }
|
||||||
void SetStr( const char* str, int flags=0 );
|
void SetStr( const char* str, int flags=0 );
|
||||||
|
|
||||||
char* ParseText( char* in, const char* endTag, int strFlags );
|
char* ParseText( char* in, const char* endTag, int strFlags );
|
||||||
char* ParseName( char* in );
|
char* ParseName( char* in );
|
||||||
|
|
||||||
|
|
||||||
|
|
21
xmltest.cpp
21
xmltest.cpp
|
@ -795,12 +795,23 @@ int main( int /*argc*/, const char ** /*argv*/ )
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure an attribute with a space in it succeeds.
|
// Make sure an attribute with a space in it succeeds.
|
||||||
static const char* xml = "<element attribute1=\"Test Attribute\"/>";
|
static const char* xml0 = "<element attribute1= \"Test Attribute\"/>";
|
||||||
XMLDocument doc;
|
static const char* xml1 = "<element attribute1 =\"Test Attribute\"/>";
|
||||||
doc.Parse( xml );
|
static const char* xml2 = "<element attribute1 = \"Test Attribute\"/>";
|
||||||
|
XMLDocument doc0;
|
||||||
|
doc0.Parse( xml0 );
|
||||||
|
XMLDocument doc1;
|
||||||
|
doc1.Parse( xml1 );
|
||||||
|
XMLDocument doc2;
|
||||||
|
doc2.Parse( xml2 );
|
||||||
|
|
||||||
XMLElement* ele = doc.FirstChildElement();
|
XMLElement* ele = 0;
|
||||||
XMLTest( "Attribute with space", "Test Attribute", ele->Attribute( "attribute1" ) );
|
ele = doc0.FirstChildElement();
|
||||||
|
XMLTest( "Attribute with space #1", "Test Attribute", ele->Attribute( "attribute1" ) );
|
||||||
|
ele = doc1.FirstChildElement();
|
||||||
|
XMLTest( "Attribute with space #2", "Test Attribute", ele->Attribute( "attribute1" ) );
|
||||||
|
ele = doc2.FirstChildElement();
|
||||||
|
XMLTest( "Attribute with space #3", "Test Attribute", ele->Attribute( "attribute1" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue