biqqles / textricate

Export messages from Textra to XML
BSD Zero Clause License
5 stars 1 forks source link

More robust escape characters #2

Closed soraxas closed 5 years ago

soraxas commented 5 years ago

First of all thanks for the helpful script it helps me a lot on converting my textricate database :)

When I first ran your script I had some problem in parsing the result xml, which I later found that some of the characters are not escaped properly. This PR uses the build in xml escape module to escape characters &, <, and > into &amp;, &lt;, and &gt; respectively (which I was having problem with before).

We couldn't use the xml.sax.saxutils.quoteattr to escape the quotes as it will adds a surrounding quotes to the string (see docs), therefore the replace is still needed.

biqqles commented 5 years ago

Thanks for pointing this out! Not escaping everything was a major oversight on my part. However I think we can accomplish this slightly more neatly using the quoteattr you linked to. If you can confirm this works I'll merge.

(Sorry about the git-spam, kept making silly mistakes.)

soraxas commented 5 years ago

Yea looks good to me, thanks for the updates!

biqqles commented 5 years ago

Great!