guix-commits
[Top][All Lists]
Advanced

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

02/02: pull: Gracefully handle invalid Texinfo markup in news.


From: guix-commits
Subject: 02/02: pull: Gracefully handle invalid Texinfo markup in news.
Date: Fri, 1 Nov 2019 07:23:59 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 6330db4d55bf9be3702cc03145470c970fb7ae9b
Author: Ludovic Courtès <address@hidden>
Date:   Fri Nov 1 12:21:26 2019 +0100

    pull: Gracefully handle invalid Texinfo markup in news.
    
    Reported by Oleg Pykhalov <address@hidden>.
    
    * 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.
---
 guix/scripts/pull.scm | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 80d0706..92aac60 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))



reply via email to

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