Skip to content

Commit

Permalink
fixed GH# 128: DOMWriter incorrectly adds SYSTEM keyword to DTD if PU…
Browse files Browse the repository at this point in the history
…BLIC is already specified
  • Loading branch information
obiltschnig committed May 24, 2013
1 parent f6faa10 commit f1ebbdf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Release 1.4.6p2 (2013-06-xx)
- fixed GH# 189: Poco::NumberParser::tryParse() documentation bug
- fixed GH# 172: IPv6 Host field is stripped of Brackets in HTTPClientSession
- fixed GH# 188: Net: SocketAddress operator < unusable for std::map key
- fixed GH# 128: DOMWriter incorrectly adds SYSTEM keyword to DTD if PUBLIC is
already specified


Release 1.4.6p1 (2013-03-06)
Expand Down Expand Up @@ -1837,4 +1839,4 @@ building the libraries.


--
$Id: //poco/1.4/dist/CHANGELOG#82 $
$Id: //poco/1.4/dist/CHANGELOG#83 $
8 changes: 6 additions & 2 deletions XML/src/XMLWriter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// XMLWriter.cpp
//
// $Id: //poco/1.4/XML/src/XMLWriter.cpp#5 $
// $Id: //poco/1.4/XML/src/XMLWriter.cpp#6 $
//
// Library: XML
// Package: XML
Expand Down Expand Up @@ -493,7 +493,11 @@ void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const
}
if (!systemId.empty())
{
writeMarkup(" SYSTEM \"");
if (publicId.empty())
{
writeMarkup(" SYSTEM");
}
writeMarkup(" \"");
writeXML(systemId);
writeMarkup("\"");
}
Expand Down
21 changes: 20 additions & 1 deletion XML/testsuite/src/XMLWriterTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// XMLWriterTest.cpp
//
// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.cpp#3 $
// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.cpp#4 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
Expand Down Expand Up @@ -169,6 +169,24 @@ void XMLWriterTest::testDTD()
}


void XMLWriterTest::testDTDPublic()
{
std::ostringstream str;
XMLWriter writer(str, XMLWriter::WRITE_XML_DECLARATION);
writer.setNewLine("\n");
writer.startDocument();
writer.startDTD("test", "test", "http://www.appinf.com/DTDs/test");
writer.endDTD();
writer.startElement("", "", "foo");
writer.endElement("", "", "foo");
writer.endDocument();
std::string xml = str.str();
assert (xml == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<!DOCTYPE test PUBLIC \"test\" \"http://www.appinf.com/DTDs/test\">"
"<foo/>");
}


void XMLWriterTest::testDTDNotation()
{
std::ostringstream str;
Expand Down Expand Up @@ -621,6 +639,7 @@ CppUnit::Test* XMLWriterTest::suite()
CppUnit_addTest(pSuite, XMLWriterTest, testTrivialFragmentPretty);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDPretty);
CppUnit_addTest(pSuite, XMLWriterTest, testDTD);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDPublic);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDNotation);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDEntity);
CppUnit_addTest(pSuite, XMLWriterTest, testAttributes);
Expand Down
3 changes: 2 additions & 1 deletion XML/testsuite/src/XMLWriterTest.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// XMLWriterTest.h
//
// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.h#1 $
// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.h#2 $
//
// Definition of the XMLWriterTest class.
//
Expand Down Expand Up @@ -54,6 +54,7 @@ class XMLWriterTest: public CppUnit::TestCase
void testTrivialFragmentPretty();
void testDTDPretty();
void testDTD();
void testDTDPublic();
void testDTDNotation();
void testDTDEntity();
void testAttributes();
Expand Down

0 comments on commit f1ebbdf

Please sign in to comment.