emacs-orgmode
[Top][All Lists]
Advanced

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

[O] org-feed-parse-atom-feed doesn't handle empty value


From: Myles English
Subject: [O] org-feed-parse-atom-feed doesn't handle empty value
Date: Mon, 07 Jan 2019 10:22:20 +0000
User-agent: mu4e 1.0; emacs 26.1

Hello,

I think there is a problem in org-feed-update in that it doesn't handle
an entry containing an element with no value, like this:

<content type="html"></content>

For example, adding an entry in org-feed-alist for an atom feed that
fails like this is:

("Artanis"
         "https://gitlab.com/NalaGinrut/artanis/tags?format=atom";
         "~/feeds.org" "Artanis"
         :parse-entry org-feed-parse-atom-entry
         :parse-feed org-feed-parse-atom-feed
         :template "* TODO %title\n")

and calling org-feed-update results in a backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  
string-match("&\\(?:#\\(x\\)?\\([0-9a-fA-F]+\\)\\|\\([[:word:]:_][-0-9.[:word:]:_·̀-ͯ‿-⁀]*\\)\\);"
 nil)
  xml-substitute-special(nil)
  (plist-put entry :description (xml-substitute-special (car (xml-node-children 
content))))
  (setq entry (plist-put entry :description (xml-substitute-special (car 
(xml-node-children content)))))
  (cond ((string= type "text") (setq entry (plist-put entry :description
  (xml-substitute-special (car (xml-node-children content))))))
  ((string= type "html") (setq entry (plist-put entry :description
  (xml-substitute-special (car (xml-node-children content))))))
  ((string= type "xhtml") (setq entry (plist-put entry :description
  (prin1-to-string (xml-node-children content))))) (t (setq entry
  (plist-put entry :description (format-message "Unknown `%s' content."
  type)))))
  (progn (cond ((string= type "text") (setq entry (plist-put entry
  :description (xml-substitute-special (car (xml-node-children
  content)))))) ((string= type "html") (setq entry (plist-put entry
  :description (xml-substitute-special (car (xml-node-children
  content)))))) ((string= type "xhtml") (setq entry (plist-put entry
  :description (prin1-to-string (xml-node-children content))))) (t (setq
  entry (plist-put entry :description (format-message "Unknown `%s'
  content." type))))))
  (if content (progn (cond ((string= type "text") (setq entry (plist-put
  entry :description (xml-substitute-special (car (xml-node-children
  content)))))) ((string= type "html") (setq entry (plist-put entry
  :description (xml-substitute-special (car (xml-node-children
  content)))))) ((string= type "xhtml") (setq entry (plist-put entry
  :description (prin1-to-string (xml-node-children content))))) (t (setq
  entry (plist-put entry :description (format-message "Unknown `%s'
  content." type)))))))
  (let* ((content (car (xml-get-children xml 'content))) (type
  (xml-get-attribute-or-nil content 'type))) (if content (progn (cond
  ((string= type "text") (setq entry (plist-put entry :description
  (xml-substitute-special (car (xml-node-children content))))))
  ((string= type "html") (setq entry (plist-put entry :description
  (xml-substitute-special (car (xml-node-children content))))))
  ((string= type "xhtml") (setq entry (plist-put entry :description
  (prin1-to-string (xml-node-children content))))) (t (setq entry
  (plist-put entry :description (format-message "Unknown `%s' content."
  type))))))))
  (let ((xml (car (read-from-string (plist-get entry
  :item-full-text))))) (setq entry (plist-put entry :link
  (xml-get-attribute (car (xml-get-children xml 'link)) 'href))) (setq
  entry (plist-put entry :title (xml-substitute-special (car
  (xml-node-children (car (xml-get-children xml 'title))))))) (let*
  ((content (car (xml-get-children xml 'content))) (type
  (xml-get-attribute-or-nil content 'type))) (if content (progn (cond
  ((string= type "text") (setq entry (plist-put entry :description
  (xml-substitute-special (car (xml-node-children content))))))
  ((string= type "html") (setq entry (plist-put entry :description
  (xml-substitute-special (car (xml-node-children content))))))
  ((string= type "xhtml") (setq entry (plist-put entry :description
  (prin1-to-string (xml-node-children content))))) (t (setq entry
  (plist-put entry :description (format-message "Unknown `%s' content."
  type)))))))) entry)
  org-feed-parse-atom-entry((:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1\";))) \"\n
  \" (title nil \"v0.0.1\") \"\n \" (summary nil \"first release\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil :link
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1"; :title "v0.0.1"))
  mapcar(org-feed-parse-atom-entry ((:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1\";))) \"\n
  \" (title nil \"v0.0.1\") \"\n \" (summary nil \"first release\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil :link
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.0.1"; :title "v0.0.1")
  (:guid "https://gitlab.com/NalaGinrut/artanis/tags/v0.0.2";
  :item-full-text "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.2\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.2\";))) \"\n
  \" (title nil \"v0.0.2\") \"\n \" (summary nil \"release 0.0.2\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.0.3"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.3\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.0.3\";))) \"\n
  \" (title nil \"v0.0.3\") \"\n \" (summary nil \"release v0.0.3\")
  \"\n \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.1.0"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.1.0\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.1.0\";))) \"\n
  \" (title nil \"v0.1.0\") \"\n \" (summary nil \"release v0.1.0\")
  \"\n \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.1.1"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.1.1\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.1.1\";))) \"\n
  \" (title nil \"v0.1.1\") \"\n \" (summary nil \"Release v0.1.1\")
  \"\n \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.1.2"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.1.2\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.1.2\";))) \"\n
  \" (title nil \"v0.1.2\") \"\n \" (summary nil \"release 0.1.2\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.2"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2\";))) \"\n
  \" (title nil \"v0.2\") \"\n \" (summary nil \"release 0.2\") \"\n \"
  (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.2.1"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.1\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.1\";))) \"\n
  \" (title nil \"v0.2.1\") \"\n \" (summary nil \"release 0.2.1\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.2.2"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.2\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.2\";))) \"\n
  \" (title nil \"v0.2.2\") \"\n \" (summary nil \"release 0.2.2\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.2.3"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.3\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.3\";))) \"\n
  \" (title nil \"v0.2.3\") \"\n \" (summary nil \"release 0.2.3\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.2.4"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.4\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.4\";))) \"\n
  \" (title nil \"v0.2.4\") \"\n \" (summary nil \"release 0.2.4\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.2.5"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.5\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.2.5\";))) \"\n
  \" (title nil \"v0.2.5\") \"\n \" (summary nil \"release 0.2.5\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/9a606d9c4e90d963463107046aa61e70?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil) (:guid
  "https://gitlab.com/NalaGinrut/artanis/tags/v0.3.1"; :item-full-text
  "(entry nil \"\n \" (id nil
  \"https://gitlab.com/NalaGinrut/artanis/tags/v0.3.1\";) \"\n \" (link
  ((href . \"https://gitlab.com/NalaGinrut/artanis/tags/v0.3.1\";))) \"\n
  \" (title nil \"v0.3.1\") \"\n \" (summary nil \"release 0.3.1\") \"\n
  \" (content ((type . \"html\"))) \"\n \" (media:thumbnail ((width
  . \"40\") (height . \"40\") (url
  . 
\"https://secure.gravatar.com/avatar/d723c5a2392e7a988cc3897deef2f3c9?s=80&d=identicon\";)))
  \"\n \" (author nil \"\n \" (name nil \"Nala Ginrut\") \"\n \" (email
  nil \"address@hidden") \"\n \") \"\n\")" :handled nil)))
  org-feed-update("Artanis")
  funcall-interactively(org-feed-update "Artanis")
  call-interactively(org-feed-update record nil)
  command-execute(org-feed-update record)
  execute-extended-command(nil "org-feed-update"
  
#("org-fee\norg-feed-goto-inbox\norg-feed-show-raw-feed\norg-feed-update\norg-feed-update-all"
  7 8 (read-only nil) 8 14 (face ((:foreground "black")
  (background-color . "#6a3888a1a246") . ivy-minibuffer-match-face-2)
  mouse-face ivy-minibuffer-match-highlight help-echo (format (if
  tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s mouse-3: %s")
  ivy-mouse-1-tooltip ivy-mouse-3-tooltip) read-only nil) 14 27
  (mouse-face ivy-minibuffer-match-highlight help-echo (format (if
  tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s mouse-3: %s")
  ivy-mouse-1-tooltip ivy-mouse-3-tooltip) face ((:foreground "black")
  ivy-current-match) read-only nil) 27 28 (read-only nil) 28 34 (face
  ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 34 50 (mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 50 51 (read-only nil) 51 57 (face
  ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 57 66 (mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 66 67 (read-only nil) 67 73 (face
  ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 73 86 (mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil)))
  funcall-interactively(execute-extended-command nil "org-feed-update"
  
#("org-fee\norg-feed-goto-inbox\norg-feed-show-raw-feed\norg-feed-update\norg-feed-update-all"
  7 8 (read-only nil) 8 14 (face ((:foreground "black")
  (background-color . "#6a3888a1a246") . ivy-minibuffer-match-face-2)
  mouse-face ivy-minibuffer-match-highlight help-echo (format (if
  tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s mouse-3: %s")
  ivy-mouse-1-tooltip ivy-mouse-3-tooltip) read-only nil) 14 27
  (mouse-face ivy-minibuffer-match-highlight help-echo (format (if
  tooltip-mode "mouse-1: %s\nmouse-3: %s" "mouse-1: %s mouse-3: %s")
  ivy-mouse-1-tooltip ivy-mouse-3-tooltip) face ((:foreground "black")
  ivy-current-match) read-only nil) 27 28 (read-only nil) 28 34 (face
  ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 34 50 (mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 50 51 (read-only nil) 51 57 (face
  ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 57 66 (mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 66 67 (read-only nil) 67 73 (face
  ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil) 73 86 (mouse-face ivy-minibuffer-match-highlight
  help-echo (format (if tooltip-mode "mouse-1: %s\nmouse-3: %s"
  "mouse-1: %s mouse-3: %s") ivy-mouse-1-tooltip ivy-mouse-3-tooltip)
  read-only nil)))
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Changing this allows it to finish as expected:

lisp/org-feed.el
@@ -698,7 +698,8 @@ formatted as a string, not the original XML data."
          ;; TODO: convert HTML to Org markup.
          (setq entry (plist-put entry :description
                                 (xml-substitute-special
-                                 (car (xml-node-children content))))))
+                                 (or (car (xml-node-children content))
+                                     "")))))
         ((string= type "xhtml")
          ;; TODO: convert XHTML to Org markup.
          (setq entry (plist-put entry :description

I don't know if it is the right way to solve the problem, if it is then
there are some other places in the same cond block that would also need
changing.

Myles



reply via email to

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