Opened 12 years ago

Closed 11 years ago

#5413 closed Bugs (duplicate)

(read_xml + write_xml) do not restitute escape sequences in tag's attribute stri

Reported by: misterwallas@… Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

Description

Use the following program to read/write to/from a ptree an XML file containing XML escape sequences in tag's attribute string.

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

using boost::property_tree::ptree;

int main()
{
  ptree pt;
  read_xml("xml-esc-in.xml", pt);
  write_xml("xml-esc-out.xml", pt);

  return 0;
}
  • With the following XML input file

xml-esc-in.xml

<?xml version="1.0" encoding="UTF-8"?>
<html>
 <head>
  <title>Title</title>
   <link title="&lt;&gt;&quot;&apos;&amp;" href="" />
 </head>
 <body>
  <p>
   &lt;&gt;&quot;&apos;&amp;
  </p>
 </body>
</html>
  • It will give you the following XML output file

xml-esc-out.xml

<?xml version="1.0" encoding="utf-8"?>
<html>
  <head>
    <title>Title</title>
    <link title="<>"'&" href=""/>
  </head>
  <body>
    <p>
      &lt;&gt;&quot;&apos;&amp;
    </p>
  </body>
</html>
  • Escape sequences in the [title] attribute of the <link> tag have been translated into their ascii equivalent resulting in an invalid XML.

Attachments (3)

write-xml.cpp (232 bytes ) - added by anonymous 12 years ago.
xml-esc-in.xml (212 bytes ) - added by anonymous 12 years ago.
xml-esc-out.xml (187 bytes ) - added by misterwallas@… 12 years ago.

Download all attachments as: .zip

Change History (5)

by anonymous, 12 years ago

Attachment: write-xml.cpp added

by anonymous, 12 years ago

Attachment: xml-esc-in.xml added

by misterwallas@…, 12 years ago

Attachment: xml-esc-out.xml added

comment:1 by anonymous, 12 years ago

Component: Noneproperty_tree
Owner: set to Sebastian Redl

comment:2 by Sebastian Redl, 11 years ago

Resolution: duplicate
Status: newclosed

Dupe of bug 4840.

Note: See TracTickets for help on using tickets.