Boost C++ Libraries: Ticket #1038: "<" and ">" should be excaped in xml_oarchive https://svn.boost.org/trac10/ticket/1038 <p> Using templates in BOOST_CLASS_EXPORT fails for XML Archives, because the characters "&lt;" and "&gt;" enclosing the template-parameters aren't escaped. Using templates for other Archives works, so this should be corrected for XML Archives. The xml_iarchive is already correct and understands &amp;gt; respective &amp;lt;. </p> <p> I could reproduce the bug for Boost 1.33.1 and 1.34.0. I'll append a testcase, where the Bug should be reproducable and a patch to fix it. </p> <p> Yours sincerely, René Bürgel </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1038 Trac 1.4.3 r.buergel@… Thu, 07 Jun 2007 13:11:09 GMT attachment set https://svn.boost.org/trac10/ticket/1038 https://svn.boost.org/trac10/ticket/1038 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Test.cpp</span> </li> </ul> <p> Testcase </p> Ticket r.buergel@… Thu, 07 Jun 2007 13:12:27 GMT attachment set https://svn.boost.org/trac10/ticket/1038 https://svn.boost.org/trac10/ticket/1038 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">300-writing-lt-gt.patch</span> </li> </ul> <p> patch </p> Ticket Eric Niebler Wed, 11 Jul 2007 01:59:14 GMT owner set https://svn.boost.org/trac10/ticket/1038#comment:1 https://svn.boost.org/trac10/ticket/1038#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Robert Ramey</span> </li> </ul> Ticket Robert Ramey Wed, 11 Jul 2007 03:35:49 GMT <link>https://svn.boost.org/trac10/ticket/1038#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1038#comment:2</guid> <description> <p> "Using templates for other Archives works, so this should be corrected for XML Archives." </p> <p> I can't see how this would be true. I'll look into it </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <author>r.buergel@…</author> <pubDate>Mon, 27 Aug 2007 13:26:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1038#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1038#comment:3</guid> <description> <p> Did you find some time for it? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Fri, 30 Nov 2007 20:37:44 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1038#comment:4 https://svn.boost.org/trac10/ticket/1038#comment:4 <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> I've examined your test case, which boils down to: </p> <p> <em>typedef B&lt;int&gt; bint; BOOST_CLASS_EXPORT( B&lt;int&gt; ) </em></p> <p> With your suggestion, this would generate xml that looks like; </p> <p> &lt;B&amp;lt;int&amp;gt; ...&gt;...&lt;/B&amp;lt;int&amp;gt;&gt; </p> <p> Is this legal xml? </p> <p> Assuming it is, is this good idea? </p> <p> Without making a better case for this, I would be disinclined to alterh the library. </p> <p> Robert Ramey </p> Ticket r.buergel@… Mon, 03 Dec 2007 09:48:04 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/1038#comment:5 https://svn.boost.org/trac10/ticket/1038#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> It looks like we're talking about two different things here. </p> <p> The suggested patch just changed the generated xml from &lt;b class_id="1" class_name="B&lt;int&gt;" ...&gt; to &lt;b class_id="1" class_name="B&amp;lt;int&amp;gt;" ...&gt; </p> <p> I'm not sure, if class_name="B&lt;int&gt;" is valid XML, but i think so. At least it is unambiguous, because the angle brackets are enclosed by quotation marks. So, at a closer look, the xml-parser may be the real cause of the problem and my patch is more the workaround for this. </p> <p> The case you are describing above doesn't come from using "BOOST_CLASS_EXPORT ( B&lt;int&gt; )", but from "ar &amp; BOOST_SERIALIZATION_BASE_OBJECT_NVP( B&lt;int&gt; )". I added it to my testcase and at a quick view, that also seems to work for other archive types like text_archive, but fails for xml_archives. But for that case, the xml_oarchive fails, not the iarchive. So it is recognized when writing the serialization, and not until reading it. </p> <p> I'd like to find a solution here. In the best case, the xml-reader is fixed to read class_name="B&lt;int&gt;", IF that is valid xml. But at least, the xml_oarchive should not be able to create archives, that can't be read by the xml_iarchive. </p> Ticket r.buergel@… Tue, 04 Dec 2007 10:36:30 GMT <link>https://svn.boost.org/trac10/ticket/1038#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1038#comment:6</guid> <description> <p> Ok, i looked it up in the XML specs ( <a class="ext-link" href="http://www.w3.org/TR/2006/REC-xml-20060816/"><span class="icon">​</span>http://www.w3.org/TR/2006/REC-xml-20060816/</a> ), what is valid xml and what not. </p> <p> &lt;b class_id="1" class_name="B&lt;int&gt;" ...&gt; is invalid, because the left angle bracket is forbidden in attribute values. The escaped variant &lt;b class_id="1" class_name="B&amp;lt;int&amp;gt;" ...&gt; is valid. </p> <p> The case you described above ( &lt;B&amp;lt;int&amp;gt; ...&gt;...&lt;/B&amp;lt;int&amp;gt;&gt; ) is clearly invalid. But it didn't work before my patch and it doesn't work after applying it, because the xml_oarchive throws an exception, which states "Unrecognized XML Syntax". </p> <p> So, currently it is possible to write invalid xml with you archive without getting trapped. But reading that invalid xml-file causes the application to fail. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Sat, 22 Dec 2007 21:40:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1038#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1038#comment:7</guid> <description> <p> OK </p> <p> First, thanks for spending time on this. We're now at the point where you've looked at it more deeply than I have. Does your patch: </p> <p> a) create class_name="B&amp;lt;int&amp;gt" on output b) and permit class_name="B&amp;lt;int&amp;gt" in input? c) trap usage of &lt; and &gt; in variable names on output? </p> <p> If not, can it be enhanced to do so? This to me would be a definitive solution to the the problem and guarentee that any archive that is successfully written with xml_oarchive can be successfully read by xml_iarchive - which is where I want the real situation to be. </p> <p> Robert Ramey </p> <p> Would this not resolve the issue </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Sun, 23 Dec 2007 22:43:52 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/1038#comment:8 https://svn.boost.org/trac10/ticket/1038#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.36.0</span> </li> </ul> <p> OK, you've convinced me. I'm putting it in and testing it. </p> <p> Robert Ramey </p> Ticket