[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: XML entities in the ox-rss exporter

From: Arun Isaac
Subject: Re: [O] Bug: XML entities in the ox-rss exporter
Date: Wed, 25 May 2016 15:42:00 +0530
User-agent: mu4e 0.9.17; emacs 24.5.1

>> I can provide a patch for this. 

Please find attached the patch.

> Since "ox-rss.el" loads "ox-html", could you re-use code in the latter?

I think even ox-html could benefit from using an XML/HTML generation
library that can convert s-expressions to XML/HTML. xml.el has
`xml-parse-region' to convert XML strings to an s-expression tree, but
unfortunately has no function to do the inverse, that is, convert an
s-expression tree to an XML string. If it had such a function, we
needn't have to depend on an external library such as xmlgen, and things
would have been more convenient.

Anyways, for now, I have implemented a patch which uses
`org-rss-plain-text' (which, in turn uses `org-html-encode-plain-text')
to encode the disallowed characters to their XML entities.

Attachment: signature.asc
Description: PGP signature

>From 2b310b32234e6193154c9850d51aaa8ed312f2df Mon Sep 17 00:00:00 2001
From: Arun Isaac <address@hidden>
Date: Wed, 25 May 2016 15:11:34 +0530
Subject: [PATCH] ox-rss: Encode characters to their XML entities

* contrib/lisp/ox-rss.el (org-rss-build-channel-info, org-rss-headline):
  Encode disallowed characters in `title' to their XML entities

The `title' field is user specified and may contain characters such as
"&", "<" or ">" that are disallowed in XML. These characters should be
encoded into their corresponding XML entities.
 contrib/lisp/ox-rss.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/contrib/lisp/ox-rss.el b/contrib/lisp/ox-rss.el
index 0c4a2f2..95d20ec 100644
--- a/contrib/lisp/ox-rss.el
+++ b/contrib/lisp/ox-rss.el
@@ -248,12 +248,13 @@ communication channel."
                             "%a, %d %b %Y %H:%M:%S %z"
                             (org-time-string-to-time pubdate0)))))
-            (title (or (org-element-property :RSS_TITLE headline)
-                       (replace-regexp-in-string
-                        org-bracket-link-regexp
-                        (lambda (m) (or (match-string 3 m)
-                                        (match-string 1 m)))
-                        (org-element-property :raw-value headline))))
+            (title (org-rss-plain-text
+                    (or (org-element-property :RSS_TITLE headline)
+                        (replace-regexp-in-string
+                         org-bracket-link-regexp
+                         (lambda (m) (or (match-string 3 m)
+                                         (match-string 1 m)))
+                         (org-element-property :raw-value headline))) info))
              (or (and hl-perm (concat (or hl-home hl-pdir) hl-perm))
@@ -318,7 +319,7 @@ as a communication channel."
 (defun org-rss-build-channel-info (info)
   "Build the RSS channel information."
   (let* ((system-time-locale "C")
-        (title (plist-get info :title))
+        (title (org-rss-plain-text (or (plist-get info :title) "") info))
         (email (org-export-data (plist-get info :email) info))
         (author (and (plist-get info :with-author)
                      (let ((auth (plist-get info :author)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]