From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Isaac Subject: Re: Bug: XML entities in the ox-rss exporter Date: Wed, 25 May 2016 15:42:00 +0530 Message-ID: <87fut6qwen.fsf@gmail.com> References: <87r3d05w5f.fsf@gmail.com> <8737p79o8m.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Vnx-0004GU-Ac for emacs-orgmode@gnu.org; Wed, 25 May 2016 06:12:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Vnr-0006Gt-87 for emacs-orgmode@gnu.org; Wed, 25 May 2016 06:12:44 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:34099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Vnq-0006Gn-Ti for emacs-orgmode@gnu.org; Wed, 25 May 2016 06:12:39 -0400 Received: by mail-pf0-x232.google.com with SMTP id y69so17093228pfb.1 for ; Wed, 25 May 2016 03:12:38 -0700 (PDT) Received: from steel ([223.227.165.146]) by smtp.gmail.com with ESMTPSA id kb15sm11580876pad.28.2016.05.25.03.12.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2016 03:12:36 -0700 (PDT) In-reply-to: <8737p79o8m.fsf@saiph.selenimh> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-org --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable >> I can provide a patch for this.=20 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. --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXRXpxAAoJEC4l7othgCuz3jsIAKvQfFyyjMja+1KssYexuBxV hUT9DZyZR4w7KcV5p2TEKkX2kuoOJiMMAtCAD9/7sD4jqSq5uBe3/8iAp6ijlbUx r+TgwtevgZIdkGiZhH3/uZ2vm3nHoaqVfxiCtZo52HcE6JlnpB9tifs7lOx/L/8r Bkw+BAQJz5eLFBGLuSp0Psd7jZQ6KMcH63JE10pQ3v0DvoU01ZgtX6YjRtFacarI i6PyCo+fOVbPkDzZQRBTm3tZM6aD7dmAQX5SoJceejsL1i/TEabtfa7XRfYxDOP3 aOKVOaZH9EAViS0RcOos+Shjq35dfgmP5L8DeMbehgIa/Vkigpu8YHyaVgqeFVA= =jNp2 -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=ox-rss-Encode-characters-to-their-XML-entities.patch >From 2b310b32234e6193154c9850d51aaa8ed312f2df Mon Sep 17 00:00:00 2001 From: Arun Isaac 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." (format-time-string "%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)) (publink (or (and hl-perm (concat (or hl-home hl-pdir) hl-perm)) (concat @@ -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))) -- 2.8.2 --=-=-=--