From: "Ludovic Courtès" <ludo@gnu.org>
To: 51332@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#51332] [PATCH 1/2] ui: Gracefully handle invalid Texinfo markup in package blurbs.
Date: Fri, 22 Oct 2021 14:45:18 +0200 [thread overview]
Message-ID: <20211022124519.28473-1-ludo@gnu.org> (raw)
In-Reply-To: <20211022124052.28197-1-ludo@gnu.org>
Previously 'guix search' & co. would crash when encountering invalid
Texinfo.
* guix/ui.scm (texi->plain-text*): New procedure.
(package-field-string, package->recutils): Use it.
---
guix/ui.scm | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 1428c254b3..eb7f0afcfd 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1431,10 +1431,22 @@ (define (texi->plain-text str)
(with-fluids ((%default-port-encoding "UTF-8"))
(stexi->plain-text (texi-fragment->stexi str))))
+(define (texi->plain-text* package str)
+ "Same as 'texi->plain-text', but gracefully handle Texinfo errors."
+ (catch 'parser-error
+ (lambda ()
+ (texi->plain-text str))
+ (lambda args
+ (warning (package-location package)
+ (G_ "~a: invalid Texinfo markup~%")
+ (package-full-name package))
+ str)))
+
(define (package-field-string package field-accessor)
"Return a plain-text representation of PACKAGE field."
(and=> (field-accessor package)
- (compose texi->plain-text P_)))
+ (lambda (str)
+ (texi->plain-text* package (P_ str)))))
(define (package-description-string package)
"Return a plain-text representation of PACKAGE description field."
@@ -1555,7 +1567,8 @@ (define (package<? p1 p2)
(parameterize ((%text-width width*))
;; Call 'texi->plain-text' on the concatenated string to account
;; for the width of "description:" in paragraph filling.
- (texi->plain-text
+ (texi->plain-text*
+ p
(string-append "description: "
(or (and=> (package-description p) P_)
""))))
--
2.33.0
next prev parent reply other threads:[~2021-10-22 12:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 12:40 [bug#51332] [PATCH 0/2] Detect early and gracefully handle invalid Texinfo Ludovic Courtès
2021-10-22 12:45 ` Ludovic Courtès [this message]
2021-10-22 12:45 ` [bug#51332] [PATCH 2/2] packages: Optionally validate Texinfo markup at expansion time Ludovic Courtès
2021-10-28 19:46 ` bug#51332: [PATCH 0/2] Detect early and gracefully handle invalid Texinfo Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211022124519.28473-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=51332@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.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).