Fix attributes escaping when writing XML.
wxXmlDocument didn't correctly escape some characters that the spec says must be escaped. Behaves correctly now. Fixes #12275. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65192 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -76,12 +76,14 @@ private:
|
||||
CPPUNIT_TEST( InsertChildAfter );
|
||||
CPPUNIT_TEST( LoadSave );
|
||||
CPPUNIT_TEST( CDATA );
|
||||
CPPUNIT_TEST( Escaping );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void InsertChild();
|
||||
void InsertChildAfter();
|
||||
void LoadSave();
|
||||
void CDATA();
|
||||
void Escaping();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(XmlTestCase)
|
||||
};
|
||||
@@ -215,3 +217,26 @@ void XmlTestCase::CDATA()
|
||||
// is not
|
||||
CPPUNIT_ASSERT_EQUAL( "Giovanni Mittone", n->GetContent() );
|
||||
}
|
||||
|
||||
void XmlTestCase::Escaping()
|
||||
{
|
||||
// Verify that attribute values are escaped correctly, see
|
||||
// http://trac.wxwidgets.org/ticket/12275
|
||||
|
||||
const char *xmlText =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<root text=\"hello
this is a new line\">\n"
|
||||
" <x/>\n"
|
||||
"</root>\n"
|
||||
;
|
||||
|
||||
wxStringInputStream sis(xmlText);
|
||||
|
||||
wxXmlDocument doc;
|
||||
CPPUNIT_ASSERT( doc.Load(sis) );
|
||||
|
||||
wxStringOutputStream sos;
|
||||
CPPUNIT_ASSERT( doc.Save(sos) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( xmlText, sos.GetString() );
|
||||
}
|
||||
|
Reference in New Issue
Block a user