summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-11-01 12:21:26 +0100
committerLudovic Courtès <ludo@gnu.org>2019-11-01 12:23:45 +0100
commit6330db4d55bf9be3702cc03145470c970fb7ae9b (patch)
tree0c1805958ec90794aec3474bd2612a63d0cdf1c5 /guix/scripts
parent5afa23e1805e68a7cd9adb2145094dcd29bf67d6 (diff)
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.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/pull.scm40
1 files changed, 26 insertions, 14 deletions
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 80d070652b..92aac6066e 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -235,12 +235,18 @@ purposes."
(define title
(channel-news-entry-title entry))
- (format port " ~a~%"
- (highlight
- (string-trim-right
- (texi->plain-text (or (assoc-ref title language)
- (assoc-ref title (%default-message-language))
- ""))))))
+ (let ((title (or (assoc-ref title language)
+ (assoc-ref title (%default-message-language))
+ "")))
+ (format port " ~a~%"
+ (highlight
+ (string-trim-right
+ (catch 'parser-error
+ (lambda ()
+ (texi->plain-text title))
+
+ ;; When Texinfo markup is invalid, display it as-is.
+ (const title)))))))
(define (display-news-entry entry language port)
"Display ENTRY, a <channel-news-entry>, in LANGUAGE, a language code, to
@@ -252,14 +258,20 @@ PORT."
(format port (dim (G_ " commit ~a~%"))
(channel-news-entry-commit entry))
(newline port)
- (format port " ~a~%"
- (indented-string
- (parameterize ((%text-width (- (%text-width) 4)))
- (string-trim-right
- (texi->plain-text (or (assoc-ref body language)
- (assoc-ref body (%default-message-language))
- ""))))
- 4)))
+ (let ((body (or (assoc-ref body language)
+ (assoc-ref body (%default-message-language))
+ "")))
+ (format port " ~a~%"
+ (indented-string
+ (parameterize ((%text-width (- (%text-width) 4)))
+ (string-trim-right
+ (catch 'parser-error
+ (lambda ()
+ (texi->plain-text body))
+ (lambda _
+ ;; When Texinfo markup is invalid, display it as-is.
+ (fill-paragraph body (%text-width))))))
+ 4))))
(define* (display-channel-specific-news new old
#:key (port (current-output-port))