From patchwork Fri Oct 22 12:45:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34008 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7332D27BBE3; Fri, 22 Oct 2021 13:47:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4537E27BBE1 for ; Fri, 22 Oct 2021 13:47:11 +0100 (BST) Received: from localhost ([::1]:57830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdtx0-0003N3-BE for patchwork@mira.cbaines.net; Fri, 22 Oct 2021 08:47:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdtws-0003L0-Aw for guix-patches@gnu.org; Fri, 22 Oct 2021 08:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48112) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdtwr-0000ZY-Tt for guix-patches@gnu.org; Fri, 22 Oct 2021 08:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mdtwr-0003F7-St for guix-patches@gnu.org; Fri, 22 Oct 2021 08:47:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51332] [PATCH 1/2] ui: Gracefully handle invalid Texinfo markup in package blurbs. References: <20211022124052.28197-1-ludo@gnu.org> In-Reply-To: <20211022124052.28197-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Oct 2021 12:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51332 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51332@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51332-submit@debbugs.gnu.org id=B51332.163490677612387 (code B ref 51332); Fri, 22 Oct 2021 12:47:01 +0000 Received: (at 51332) by debbugs.gnu.org; 22 Oct 2021 12:46:16 +0000 Received: from localhost ([127.0.0.1]:59656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mdtvu-0003DM-ID for submit@debbugs.gnu.org; Fri, 22 Oct 2021 08:46:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mdtvs-0003Cb-Oj for 51332@debbugs.gnu.org; Fri, 22 Oct 2021 08:46:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42912) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdtvk-0007Pv-T4; Fri, 22 Oct 2021 08:45:53 -0400 Received: from [193.50.110.110] (port=53680 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdtvT-0002o8-9J; Fri, 22 Oct 2021 08:45:52 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 22 Oct 2021 14:45:18 +0200 Message-Id: <20211022124519.28473-1-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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 (packageplain-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_) ""))))