Merge pull request #670 from dquam/ProcessEntitiesBugWhenFalse
In PrintString, move the optimization under the if ( _processEntities…
This commit is contained in:
@@ -2523,16 +2523,18 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
|
|||||||
++q;
|
++q;
|
||||||
TIXMLASSERT( p <= q );
|
TIXMLASSERT( p <= q );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Flush the remaining string. This will be the entire
|
// Flush the remaining string. This will be the entire
|
||||||
// string if an entity wasn't found.
|
// string if an entity wasn't found.
|
||||||
TIXMLASSERT( p <= q );
|
if ( p < q ) {
|
||||||
if ( !_processEntities || ( p < q ) ) {
|
|
||||||
const size_t delta = q - p;
|
const size_t delta = q - p;
|
||||||
const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
|
const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
|
||||||
Write( p, toPrint );
|
Write( p, toPrint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Write( p );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
|
void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
|
||||||
|
|||||||
11
xmltest.cpp
11
xmltest.cpp
@@ -1995,6 +1995,17 @@ int main( int argc, const char ** argv )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char* html("<!DOCTYPE html><html><body><p>test</p><p><br/></p></body></html>");
|
||||||
|
XMLDocument doc(false);
|
||||||
|
doc.Parse(html);
|
||||||
|
|
||||||
|
XMLPrinter printer(0, true);
|
||||||
|
doc.Print(&printer);
|
||||||
|
|
||||||
|
XMLTest(html, html, printer.CStr());
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Evil memory leaks.
|
// Evil memory leaks.
|
||||||
// If an XMLElement (etc) is allocated via NewElement() (etc.)
|
// If an XMLElement (etc) is allocated via NewElement() (etc.)
|
||||||
|
|||||||
Reference in New Issue
Block a user