OPML import double-decodes character entities

OPML import double-decodes character entities. Scrivener v2.1 14114, on Mac OS X 10.7.1.

To reproduce:

  1. Create a text file named “test.opml” with the following contents:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <opml version="1.0"> <head> <title>Test</title> <dateCreated>2011-08-28 22:53:50.139612</dateCreated> </head> <body> <outline text="Developing a Java App" _note="...a root element of &lt;code&gt;&amp;lt;web-app&amp;gt;&lt;/code&gt;. To map URL..."></outline> </body> </opml>

  1. Open Scrivener, and create a new empty project (or use an existing project).

  2. Drag the “test.opml” file from the Finder into the Binder. One new topic entitled “Developing a Java App” is created.

  3. Select the new topic to view it in the editor.

Expected behavior: The content of the topic should be: ...a root element of <code><web-app></code>. To map URL...

Actual behavior: The content of the topic is: ...a root element of <code><web-app></code>. To map URL...

Motivation for a fix: I made tools to import and export DocBook XML to and from Scrivener, using OPML as an intermediate format. Unfortunately, this double-encoding bug corrupts my import. I can work around it for personal use (search-replace “&lt;” with “::LT::” prior to import, then search-and-replace it back within Scrivener), but I’m not comfortable releasing the tool for general use until this is fixed.

Let me know if there is anything I can do to help. Thanks!

– Dan

Hi Dan,

Thanks for bringing this to my attention. The problem is that, when running through the character codes to replace, Scrivener is decoding “&” first; thus when it comes to what had been “&lt;”, it is now “<” and gets decoded. I have (I hope) fixed this by moving the “&” decoding to last.

Please try this build to see if it fixes it for you:

literatureandlatte.com/dlbet … PMLFix.zip

Thanks and all the best,

This works great. Thanks for the quick turnaround!

I’ll probably wait for this fix to make it into a formal release before releasing my tool. I assume I’ll see this mentioned in release notes; let me know if I should track this another way. For personal use I’ll stick with this build. :slight_smile:

– Dan


Yes, this will be in the release notes for 2.1.1, which should be released officially before the end of September.

All the best,

Stunned by simple grace of OPML import. But why? Everything you do amazes me.

Thank you! :slight_smile: