Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tinyxml2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ const char* StrPair::GetStr()
}
if ( !entityFound ) {
// fixme: treat as error?
// Not a recognized entity: copy the '&' through
// verbatim. The write pointer 'q' can lag behind the
// read pointer 'p' after an earlier entity expansion,
// so '*q' must be assigned or a stale byte is emitted.
*q = *p;
++p;
++q;
}
Expand Down
12 changes: 12 additions & 0 deletions xmltest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,18 @@ int main( int argc, const char ** argv )
}
}

{
// An unrecognized entity following a recognized (expanded) entity must
// not corrupt the '&'. After "&" is collapsed the write pointer lags
// the read pointer, and the following "&bogus;" used to emit a stale
// buffer byte in place of the '&'. See issue #1082.
XMLDocument doc;
doc.Parse( "<a>&amp;&bogus;</a>" );
XMLTest( "Unrecognized entity after expansion: parse", false, doc.Error() );
XMLTest( "Unrecognized entity after expansion: text",
"&&bogus;", doc.FirstChildElement( "a" )->GetText() );
}

{
// Suppress entities.
const char* passages =
Expand Down