emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: [patch] fix: ox-rss died when an entry had an empty date [ ( @ /home/arne/.guix-profile/share/emacs/site-lisp/)]
@ 2021-01-07  1:56 Dr. Arne Babenhauserheide
  2021-01-10 23:08 ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Dr. Arne Babenhauserheide @ 2021-01-07  1:56 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2307 bytes --]



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

When creating an RSS feed, org-publish broke for me with

  signal(error ("Not an Org time string: "))
  error("Not an Org time string: %s" "")
  org-parse-time-string("")
  org-time-string-to-time("")
  (format-time-string "%a, %d %b %Y %H:%M:%S %z" (org-time-string-to-time pubdate0))
  (if pubdate0 (format-time-string "%a, %d %b %Y %H:%M:%S %z" (org-time-string-to-time pubdate0)))
  ;; …
  org-rss-headline((headline ... ...) #("<p>\nIch bin ei..." 4 395 ... 407 410 ... 492 530 ... 534 535 ... ...) (:export-options nil :back-end ... :translate-alist ... :exported-data #<hash-table eq 836/4001 0x20766a9> :input-buffer "rss-feed.org" :input-file "/home/arne/Sch..." :description "" ...))


Maybe relevant: I have date enabled in options.
#+OPTIONS: date:t

Best wishes,
Arne


From 17b6ba6f9adcd42e03ae2b606043719b2926641a Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <arne_bab@web.de>
Subject: [PATCH] ox-rss: do not die on empty date

* contrib/lisp/ox-rss.el (org-rss-headline): check for empty string
---
 contrib/lisp/ox-rss.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/lisp/ox-rss.el b/contrib/lisp/ox-rss.el
index 299d22086..97a4bfc8f 100644
--- a/contrib/lisp/ox-rss.el
+++ b/contrib/lisp/ox-rss.el
@@ -245,7 +245,7 @@ communication channel."
 			(or (org-element-property :CATEGORY headline) "") info))
 	     (pubdate0 (org-element-property :PUBDATE headline))
 	     (pubdate (let ((system-time-locale "C"))
-			(if pubdate0
+			(if (and pubdate0 (not (string-empty-p pubdate0))
 			    (format-time-string
 			     "%a, %d %b %Y %H:%M:%S %z"
 			     (org-time-string-to-time pubdate0)))))
-- 
2.29.2



Emacs  : GNU Emacs 27.1 (build 1, x86_64-unknown-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0)
Package: Org mode version  ( @ /home/arne/.guix-profile/share/emacs/site-lisp/)
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Bug: [patch] fix: ox-rss died when an entry had an empty date [ ( @ /home/arne/.guix-profile/share/emacs/site-lisp/)]
  2021-01-07  1:56 Bug: [patch] fix: ox-rss died when an entry had an empty date [ ( @ /home/arne/.guix-profile/share/emacs/site-lisp/)] Dr. Arne Babenhauserheide
@ 2021-01-10 23:08 ` Kyle Meyer
  2021-04-30  7:04   ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Meyer @ 2021-01-10 23:08 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide; +Cc: emacs-orgmode

Dr. Arne Babenhauserheide writes:

> When creating an RSS feed, org-publish broke for me with
>
>   signal(error ("Not an Org time string: "))
>   error("Not an Org time string: %s" "")
>   org-parse-time-string("")
>   org-time-string-to-time("")
[...]
> Maybe relevant: I have date enabled in options.
> #+OPTIONS: date:t

I'm not an ox-rss user and don't know if there are more realistic ways
to hit this error, but I was able to trigger it by taking an already
exported buffer of

--8<---------------cut here---------------start------------->8---
* h1
  :PROPERTIES:
  :ID:       76841adc-b233-4f6d-8446-3478f263544b
  :PUBDATE:  <2021-01-10 Sun 17:46>
  :END:
--8<---------------cut here---------------end--------------->8---

and then setting PUBDATE to an empty string and exporting again.

I'm not sure if the error you see is indicative of a larger issue,
though either way guarding against an empty string as your patch does
seems fine.  But...
 
> diff --git a/contrib/lisp/ox-rss.el b/contrib/lisp/ox-rss.el
> index 299d22086..97a4bfc8f 100644
> --- a/contrib/lisp/ox-rss.el
> +++ b/contrib/lisp/ox-rss.el
> @@ -245,7 +245,7 @@ communication channel."
>  			(or (org-element-property :CATEGORY headline) "") info))
>  	     (pubdate0 (org-element-property :PUBDATE headline))
>  	     (pubdate (let ((system-time-locale "C"))
> -			(if pubdate0
> +			(if (and pubdate0 (not (string-empty-p pubdate0))

... you're missing a closing parenthesis here.

Also, a bit downstream I see

  (if (not pubdate0) "" ;; Skip entries with no PUBDATE prop

It seems like this should be updated to look at pubdate rather than
pubdate0 to avoid "<pubDate>nil</pubDate>" for the empty string case.

What do you think?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: [patch] fix: ox-rss died when an entry had an empty date [ ( @ /home/arne/.guix-profile/share/emacs/site-lisp/)]
  2021-01-10 23:08 ` Kyle Meyer
@ 2021-04-30  7:04   ` Bastien
  0 siblings, 0 replies; 3+ messages in thread
From: Bastien @ 2021-04-30  7:04 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Dr. Arne Babenhauserheide, emacs-orgmode

Hi Kyle and Arne,

Kyle Meyer <kyle@kyleam.com> writes:

> I'm not an ox-rss user and don't know if there are more realistic ways
> to hit this error, but I was able to trigger it by taking an already
> exported buffer of
>
> * h1
>   :PROPERTIES:
>   :ID:       76841adc-b233-4f6d-8446-3478f263544b
>   :PUBDATE:  <2021-01-10 Sun 17:46>
>   :END:
>
> and then setting PUBDATE to an empty string and exporting again.
>
> I'm not sure if the error you see is indicative of a larger issue,
> though either way guarding against an empty string as your patch does
> seems fine.  

Indeed, thanks Arne for reporting this.

> Also, a bit downstream I see
>
>   (if (not pubdate0) "" ;; Skip entries with no PUBDATE prop
>
> It seems like this should be updated to look at pubdate rather than
> pubdate0 to avoid "<pubDate>nil</pubDate>" for the empty string
> case.

Indeed too.  Applied as commit 8ab1e30db in maint.

Thanks,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-30  7:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07  1:56 Bug: [patch] fix: ox-rss died when an entry had an empty date [ ( @ /home/arne/.guix-profile/share/emacs/site-lisp/)] Dr. Arne Babenhauserheide
2021-01-10 23:08 ` Kyle Meyer
2021-04-30  7:04   ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).