[Boost-bugs] [Boost C++ Libraries] #9870: boost::property_tree::write_xml_element does not encode character before writing to attribute value

Subject: [Boost-bugs] [Boost C++ Libraries] #9870: boost::property_tree::write_xml_element does not encode character before writing to attribute value
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-10 07:56:32


#9870: boost::property_tree::write_xml_element does not encode character before
writing to attribute value
-------------------------------------+---------------------------
 Reporter: Alex K Yau <alex.yau@…> | Owner: cornedbee
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_tree
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
-------------------------------------+---------------------------
 The character in attribute value is not encoded in entity names and may
 output a quote " to attribute value which escapes the attribute value and
 thus outputs a wrong value.

 if the attribute stored in attribs is ("mystring", "\"") under node x.
 The expected output string is <x mystring="&quot;"/> instead of <x
 mystring="""/>. The value is &quot;, but not null string and the quote in
 the tag should be balanced.

 This can resolve by changing
 "boost/property_tree/detail/xml_parser_write.hpp" Line 118 to 119
 from

 {{{
 stream << Ch(' ') << it->first << Ch('=') <<
           Ch('"') << it->second.template get_value<std::basic_string<Ch>
>() << Ch('"');
 }}}


 to

 {{{
 stream << Ch(' ') << it->first << Ch('=') <<
           Ch('"') << encode_char_entities(it->second.template
 get_value<std::basic_string<Ch> >()) << Ch('"');
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9870>
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