Non-escaped Atom Entry Content

Topics: Argotic.Core
Sep 16, 2008 at 6:09 PM
I've just started using Argotic, and I'm enjoying the experience very much.  I did run into an issue though, with serializing AtomEntry.Content via AtomFeed.Save() or AtomEntry.Save():

By using XmlWriter.WriteString() in the implementation of AtomContent.WriteTo(), the AtomContent.Content is HTML-escaped (e.g. turning < into &lt;), as described in MSDN (http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.writestring.aspx), but if the type is an XML type like "application/xml" (which I believe is legal according to section 4.1.3.1 of RFC 4287) I believe it should not be.

As an example, I expect this:

<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Example Feed</title>
  <link href="http://example.org/"/>
  <updated>2003-12-13T18:30:02Z</updated>
  <author>
    <name>John Doe</name>
  </author>
  <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
  <entry>
    <title>Atom-Powered Robots Run Amok</title>
    <link href="http://example.org/2003/12/13/atom03"/>
    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
    <updated>2003-12-13T18:30:02Z</updated>
    <content type="application/xml">
      <warning xmlns="http://example2.org/robots/help">
        <run>for the hills!</run>
      </warning>
    </content>
  </entry>
</feed>

but get:
...
<content type="application/xml">
  &lt;warning xmlns="http://example2.org/robots/help"&gt;&lt;run%gt;for the hills!%lt;/run%gt;&lt;/warning&gt;
</content>
...

Thanks for all the great work!

David
turbodrubin@gmail.com
Sep 16, 2008 at 7:57 PM
I am glad you are finding Argotic useful. I am hoping to have more free time to fix some critical issues like this one. If you would create/open an issue in the issue tracker with some simple repro steps, I will try to get a fix for this issue in the next minor release of the framework. Thank you for taking the time to bring this issue to my attention, I appreciate it.
Sep 16, 2008 at 9:53 PM
I created work item #11319.  Thanks for a great library!
Sep 23, 2008 at 10:32 AM
Hi David,
I've come across your issue report.

I appreciate that the code probably needs to include some checking to establish which output format is required, but do you happen to know the correct MS class to use as a writer when xml is specified?

This would certainly help Oppositional along, but I expect to face the problem you described in coming weeks, and would like to have a go at a patch when the occasion arises.
Cheers,
Ian.
Sep 23, 2008 at 5:27 PM
Hi Ian, 

I've been told to take a look at WriteRaw, but I haven't looked into it any further.  It seems to me that WriteNode might also be interesting.

I think the real trick is not just the writing of unescaped data (and don't forget reading!) but being good about following the rules laid out in section 4.1.3.1 of the RFC.  If I'm reading it correctly, a type of "text/xml" should be treated as text, but "application/xml" should be treated as XML, etc.

David
Sep 23, 2008 at 5:55 PM
David and Ian,

I have added both of you as contributors to the project, so if you are so inclined, feel free to implement a fix. I am hoping to be able to dive into working on reported issue starting in October. I apprecaite the feedback and discussions you have been providing.