Archived
1
0
Fork 0

pull: Gracefully handle invalid Texinfo markup in news.

Reported by Oleg Pykhalov <go.wigust@gmail.com>.

* guix/scripts/pull.scm (display-news-entry-title)
(display-news-entry): Catch 'parser-error' around call to
'texi->plain-text', and return Texinfo as-is when an exception is
caught.
This commit is contained in:
Ludovic Courtès 2019-11-01 12:21:26 +01:00
parent 5afa23e180
commit 6330db4d55
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -235,12 +235,18 @@ purposes."
(define title (define title
(channel-news-entry-title entry)) (channel-news-entry-title entry))
(let ((title (or (assoc-ref title language)
(assoc-ref title (%default-message-language))
"")))
(format port " ~a~%" (format port " ~a~%"
(highlight (highlight
(string-trim-right (string-trim-right
(texi->plain-text (or (assoc-ref title language) (catch 'parser-error
(assoc-ref title (%default-message-language)) (lambda ()
"")))))) (texi->plain-text title))
;; When Texinfo markup is invalid, display it as-is.
(const title)))))))
(define (display-news-entry entry language port) (define (display-news-entry entry language port)
"Display ENTRY, a <channel-news-entry>, in LANGUAGE, a language code, to "Display ENTRY, a <channel-news-entry>, in LANGUAGE, a language code, to
@ -252,14 +258,20 @@ PORT."
(format port (dim (G_ " commit ~a~%")) (format port (dim (G_ " commit ~a~%"))
(channel-news-entry-commit entry)) (channel-news-entry-commit entry))
(newline port) (newline port)
(let ((body (or (assoc-ref body language)
(assoc-ref body (%default-message-language))
"")))
(format port " ~a~%" (format port " ~a~%"
(indented-string (indented-string
(parameterize ((%text-width (- (%text-width) 4))) (parameterize ((%text-width (- (%text-width) 4)))
(string-trim-right (string-trim-right
(texi->plain-text (or (assoc-ref body language) (catch 'parser-error
(assoc-ref body (%default-message-language)) (lambda ()
"")))) (texi->plain-text body))
4))) (lambda _
;; When Texinfo markup is invalid, display it as-is.
(fill-paragraph body (%text-width))))))
4))))
(define* (display-channel-specific-news new old (define* (display-channel-specific-news new old
#:key (port (current-output-port)) #:key (port (current-output-port))