Subject: [Boost-bugs] [Boost C++ Libraries] #10338: Boost.PropertyTree update to v1.56 breaks existing code
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-10 17:52:20
#10338: Boost.PropertyTree update to v1.56 breaks existing code
-------------------------------------+---------------------------
Reporter: Pieter | Owner: cornedbee
Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_tree
Version: Boost 1.56.0 | Severity: Regression
Keywords: Escape sequence problem |
-------------------------------------+---------------------------
Commit 4e7aa973f95b7151282ebcb77dd4cb9316fe920c ("Escape newlines and tabs
in content when writing XML.") has broken my code.
Under certain circumstances, write_xml now produces an XML that starts
with:
<?xml version=\"1.0\"
encoding=\"utf-8\"?>\n <Level_2><Item>0</Item></Level_2>
which cannot be parsed by read_xml (an exception is thrown). Version 1.55
did not have this issue as it did not produce the escape sequence that
read_xml chokes on.
Below I have included a unit test that reproduces the problem.
BOOST_AUTO_TEST_CASE(ReadAndWriteWithSpecialCharacters)
{
using boost::property_tree::ptree;
// the xml that will be turned into a ptree. Note the linefeed between
Level_1 and Level_2 tags
std::string XmlString = "<?xml version=\"1.0\"
encoding=\"utf-8\"?><Level_1>\n<Level_2><Item>0</Item></Level_2></Level_1>";
std::stringstream StringStream1(XmlString);
std::stringstream StringStream2;
// read the xml string
ptree Level1Tree;
read_xml(StringStream1,Level1Tree);
// write the sub-tree at level 1 to string stream 2 as an xml
ptree Level2Tree = Level1Tree.get_child("Level_1");
write_xml(StringStream2,Level2Tree);
// show that the xml string has an xml declaration followed by \n
(boost version 1.56)
// or an xml declaration followed by \n\n (boost version 1.55 and
earlier)
std::string Level2XmlString = StringStream2.str();
if (BOOST_VERSION >= 105600)
{
BOOST_CHECK(Level2XmlString == "<?xml version=\"1.0\"
encoding=\"utf-8\"?>\n <Level_2><Item>0</Item></Level_2>");
}
else
{
BOOST_CHECK(Level2XmlString == "<?xml version=\"1.0\"
encoding=\"utf-8\"?>\n\n<Level_2><Item>0</Item></Level_2>");
}
// reading the xml from string stream 2 throws an exception in boost
1.56 but not in boost 1.55
ptree OutputTree;
BOOST_CHECK_NO_THROW(read_xml(StringStream2,OutputTree));
}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10338> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC