Boost C++ Libraries: Ticket #4340: property_tree xml parser failed to handle wstream with i18n char https://svn.boost.org/trac10/ticket/4340 <p> boost::property_tree::read_xml(wistream&amp;, wptree&amp;) throw exception if tag/value/attribute has a unicode with '\0' inside, </p> <p> for example, for chinese character L'\u4E00', an exception will be throwed because the parser treat L'\u4E00' as '\0'. </p> <p> for example, the following test case won't pass: </p> <p> BOOST_AUTO_TEST_CASE(test_i18n_xml_tag_name) { </p> <blockquote> <p> wistringstream in(L"&lt;\u4E00&gt;abc&lt;/\u4E00&gt;"); property_tree::wptree pt; BOOST_REQUIRE_NO_THROW(property_tree::read_xml(in, pt)); BOOST_CHECK(L"abc" == pt.get&lt;wstring&gt;(L"\u4E00")); </p> </blockquote> <p> } </p> <p> BOOST_AUTO_TEST_CASE(test_i18n_xml_attribute_name) { </p> <blockquote> <p> wistringstream in(L"&lt;tag \u4E00=\"abc\"&gt;def&lt;/tag&gt;"); property_tree::wptree pt; BOOST_REQUIRE_NO_THROW(property_tree::read_xml(in, pt)); BOOST_CHECK(L"abc" == pt.get&lt;wstring&gt;(L"tag.&lt;xmlattr&gt;.\u4E00")); </p> </blockquote> <p> } </p> <p> BOOST_AUTO_TEST_CASE(test_i18n_xml_attribute_value) { </p> <blockquote> <p> wistringstream in(L"&lt;tag attribute=\"\u4E00\"&gt;def&lt;/tag&gt;"); property_tree::wptree pt; BOOST_REQUIRE_NO_THROW(property_tree::read_xml(in, pt)); BOOST_CHECK(L"\u4E00" == pt.get&lt;wstring&gt;(L"tag.&lt;xmlattr&gt;.attribute")); </p> </blockquote> <p> } </p> <p> BOOST_AUTO_TEST_CASE(test_i18n_xml_tag_value) { </p> <blockquote> <p> wistringstream in(L"&lt;tag&gt;\u4E00&lt;/tag&gt;"); property_tree::wptree pt; BOOST_REQUIRE_NO_THROW(property_tree::read_xml(in, pt)); BOOST_CHECK(L"\u4E00" == pt.get&lt;wstring&gt;(L"tag")); </p> </blockquote> <p> } </p> <p> The fix is treat the all char whose value above 255 same as 'z' when doing semantic action. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4340 Trac 1.4.3 zhuo.qiang@… Sun, 13 Jun 2010 15:03:19 GMT attachment set https://svn.boost.org/trac10/ticket/4340 https://svn.boost.org/trac10/ticket/4340 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">property_tree_xml_i18n_fix.patch</span> </li> </ul> <p> Fix for the property_tree xml parser parse i18n stream bug against svn revision 62903 </p> Ticket zhuo.qiang@… Wed, 20 Oct 2010 03:49:58 GMT summary, severity, version, milestone changed https://svn.boost.org/trac10/ticket/4340#comment:1 https://svn.boost.org/trac10/ticket/4340#comment:1 <ul> <li><strong>summary</strong> <span class="trac-field-old">property_tree xml parser do not handle wstream with i18n char well</span> → <span class="trac-field-new">property_tree xml parser failed to handle wstream with i18n char</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Showstopper</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost Development Trunk</span> → <span class="trac-field-new">Boost 1.44.0</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.43.0</span> → <span class="trac-field-new">Boost-1.45.0</span> </li> </ul> <p> It's better that this small patch (as well as the unit test) could go into boost 1.45 </p> Ticket Sebastian Redl Tue, 09 Nov 2010 09:55:09 GMT <link>https://svn.boost.org/trac10/ticket/4340#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4340#comment:2</guid> <description> <p> Applied on trunk, waiting for tests to cycle. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sebastian Redl</dc:creator> <pubDate>Wed, 10 Nov 2010 09:23:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4340#comment:3 https://svn.boost.org/trac10/ticket/4340#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66479" title="Merge simple fix for non-ascii XML parsing to release. Fixes bug 4340.">[66479]</a>) Merge simple fix for non-ascii XML parsing to release. Fixes bug 4340. </p> Ticket