GNU bug report logs - #75151
[PATCH] import/utils: beautify-description: Validate argument

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Morgan Smith <Morgan.J.Smith@HIDDEN>; Keywords: patch; dated Fri, 27 Dec 2024 22:22:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Dec 2024 22:21:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 27 17:21:45 2024
Received: from localhost ([127.0.0.1]:47883 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tRIiH-0003Hv-7P
	for submit <at> debbugs.gnu.org; Fri, 27 Dec 2024 17:21:45 -0500
Received: from lists.gnu.org ([209.51.188.17]:59734)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <Morgan.J.Smith@HIDDEN>) id 1tRIiE-0003Hj-LK
 for submit <at> debbugs.gnu.org; Fri, 27 Dec 2024 17:21:43 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Morgan.J.Smith@HIDDEN>)
 id 1tRIiE-0000S3-91
 for guix-patches@HIDDEN; Fri, 27 Dec 2024 17:21:42 -0500
Received: from mail-dm6nam10olkn2032.outbound.protection.outlook.com
 ([40.92.41.32] helo=NAM10-DM6-obe.outbound.protection.outlook.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Morgan.J.Smith@HIDDEN>)
 id 1tRIiC-0001b0-6R
 for guix-patches@HIDDEN; Fri, 27 Dec 2024 17:21:41 -0500
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=UiKtE5/p7cKZVpYQn4s8x4MpATJ8PoSdHV26Duy/m8lGpEJy5yr3F0bfOqgQ6qbNeCPYUHuKiLTvD+7IfoOp/Kyqp0Z0p8fZkUbugs/li1xoLDdOAIGb9m6EkHXroK7jMF+6D8vp/xLMgAIika12tpwi0xCZWwyyqxvyB9FyNLEadNtp+XKBkbb9MxI1yRvYBxKRD0lbQyRNFt/3/EGZcPlfZ8mjEA6PrAEC2ifNDXgulG6sIf1tMcnLjrViaxdmcOsBhdCAjiYQKjq64o9biUVf3B40zjGgtHlP4uFEvQg+IyToYivJiWAEYo4cqsWCKCNm2r6swZ9RQAHFUyL6+w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=nicY3ca3R92qUN1jbPcdKmXD0ZXhq/pTwlChXf8ikP8=;
 b=P7n3aQrH3KAaE3WAk73E+xk/UDQ0e7z2o91M0twEkKAnCuriVdeAFuZpSpslf+QKzsABgBCQRat1rg6WUYfDWWncvw9ku0IkUgkWbc6scfjgMboaYv3PhnDPr4nUtGVHL9NPBVqzlrFWe4peT41ywjrT46utuXKhmA9KOreC6M2kPIUmkeR0opEx7pdHrNGcUokPDzmX/RZu37a2xWZH8P18Q7fVhavL1i7zJ9nXBLyq9/HBjCxFiSZtT5DxCQCzUAfTkR1e8I4/F7tYFT/2Xn5+WMIMdlacY/kpODmOmOWyY8ke+c8Y3S98J4as/Y3PD/foHSAqxRqmcmieafCcTw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
 dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=nicY3ca3R92qUN1jbPcdKmXD0ZXhq/pTwlChXf8ikP8=;
 b=fjHWdLQh4mirJD/5rvWncVgBIRxqTP2SL5n+sf/BCT+SWr2hstsg5G2my2qFaAGNWcv5MaOJ+c0WM1Tygy9BvRlYmjw7VdxkBI5j+qRD+24sEeyNdZqhhIumxpAC6meUzMsAD7wsfLy2U/HcmvZqaBHmkXXIlgLG07d1ImbEmuzztQvpUIqB2FJA/UpDrrPejAp5UEodArbaRmRP3kCisZ81uYT0U8paQY2Kqa7CJ5rV0pI1yuSA/GDhy3Mq4+HF9lPYZ4cc6ENTCAK6BWQz5AfUHtC6FTygpX4kZmGWcGyfr+qWRWLkXYe7t1vEqC1v4fg3eJIdeUkXznQegKStIg==
Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17)
 by PH0PR84MB2025.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:160::19)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.14; Fri, 27 Dec
 2024 22:21:36 +0000
Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
 ([fe80::5c77:7a58:48ed:9aef]) by CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
 ([fe80::5c77:7a58:48ed:9aef%4]) with mapi id 15.20.8293.000; Fri, 27 Dec 2024
 22:21:36 +0000
From: Morgan Smith <Morgan.J.Smith@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] import/utils: beautify-description: Validate argument
Date: Fri, 27 Dec 2024 17:18:38 -0500
Message-ID: <CH3PR84MB3424E6AE9729DF52B792B1D5C50E2@HIDDEN>
X-Mailer: git-send-email 2.47.1
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-ClientProxiedBy: YT4PR01CA0411.CANPRD01.PROD.OUTLOOK.COM
 (2603:10b6:b01:10b::28) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
 (2603:10b6:610:1c4::17)
X-Microsoft-Original-Message-ID: <75e7d7862811d04bc08e32e92804d370173100d0.1735337917.git.Morgan.J.Smith@HIDDEN>
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|PH0PR84MB2025:EE_
X-MS-Office365-Filtering-Correlation-Id: d6804579-53ab-4d2f-039b-08dd26c4d3b4
X-Microsoft-Antispam: BCL:0;
 ARA:14566002|7092599003|8060799006|19110799003|461199028|5072599009|15080799006|3412199025|440099028|1710799026;
X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tMo+bC/IgxCIWLdezVGOa6Qa9QpMSULTZt8dMFZisyYurg8Pp7P5K4J2nPgX?=
 =?us-ascii?Q?adukt2zEJE1j0QFwqhx0NnmRgj7MBLRj+iBkUScBxkJpe1VjbpytvoC7qjni?=
 =?us-ascii?Q?96pRn/jOAAyCGJf7Sojv/tnl+mAIlEMvB/2xvcJvir4iC+/Vygxx+U36qvj0?=
 =?us-ascii?Q?Ko5fUpsuob6bROT/+0WKa11NacDIUAU94Puoju7IO6Yaaut93m1kmCVCQ70q?=
 =?us-ascii?Q?HnJbM+noMYvs7vuI9YOVoJYGXjqOkjXiHO6hVC1CfR8puBnwSqextAuy/VP4?=
 =?us-ascii?Q?j+hmdTkJ6Yn+kgXHxHCYYX7tXLt25iAgh+AH0LO4vmB5blmV8v7v1n9QNjaZ?=
 =?us-ascii?Q?GyH7ImthdtfuW0I8SntWy4A53pJiZJxqERzkZUDlk3Z3HZ+JSNdpluPDltzr?=
 =?us-ascii?Q?HNYOP4uDeL5M7SADxNgxAt4FgH25/Fie1EJ5HU3/xwp6BH4RGbCeBlVkWP3N?=
 =?us-ascii?Q?oEsGORKBxVuv8NiW2Y8fDi29du2anFGZ16xDiHdgfUP7Gyw9JJoU7dk0WaXw?=
 =?us-ascii?Q?Tif9/leT0joQ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dN?=
 =?us-ascii?Q?VRzP7omlPFqgvZnGdtmvM4DpThidE64dxMDteahhWBxJYz5hxou+2ceaxLaa?=
 =?us-ascii?Q?qlew4vTrl/fXt+ek2qDLAGjuogOHwCQEvyibYoA2QK/HWH0/mWTBLf3M3Ign?=
 =?us-ascii?Q?5gwl0t0Dl/UCeZ9Mr6POtqBE7rFUGw95yD/87K9bLyn9owJz0gELZIlLY8O/?=
 =?us-ascii?Q?C+34EjsIgEe9cuM3EbsP?=
X-OriginatorOrg: outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: d6804579-53ab-4d2f-039b-08dd26c4d3b4
X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2024 22:21:36.6320 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR84MB2025
Received-SPF: pass client-ip=40.92.41.32;
 envelope-from=Morgan.J.Smith@HIDDEN;
 helo=NAM10-DM6-obe.outbound.protection.outlook.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001,
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: Morgan Smith <Morgan.J.Smith@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

* guix/import/utils.scm (beautify-description): Fix broken check for
non-strings.  Add a check for empty strings.
* tests/import-utils.scm: Add two tests.

Change-Id: Idf86df02aeb850fcc8808b7c9251082c1f816656
---

Hello!

I was trying to run "guix import hackage orgstat" to no avail.  It turns out it
was because 'beautify-description' errors when given the empty string.  It
already had a check for arguments that where not a string but that check was
actually broken.  So I fixed the existing check and added a new one for an
empty string.

 guix/import/utils.scm  | 160 +++++++++++++++++++++--------------------
 tests/import-utils.scm |  10 +++
 2 files changed, 91 insertions(+), 79 deletions(-)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index e45c8dfb20..bb268ebe4b 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -328,85 +328,87 @@ (define* (beautify-description description #:optional (length 80))
   "Improve the package DESCRIPTION by turning a beginning sentence fragment into
 a proper sentence and by using two spaces between sentences, and wrap lines at
 LENGTH characters."
-  (unless (string? description)
-    (G_ "This package lacks a description.  Run \
-\"info '(guix) Synopses and Descriptions'\" for more information."))
-
-  (let* ((fix-word
-          (lambda (word)
-            (fold (lambda (proc acc) (proc acc)) word
-                  (list
-                   ;; Remove wrapping in single quotes, common in R packages.
-                   (cut string-trim-both <> #\')
-                   ;; Escape single @ to prevent it from being understood as
-                   ;; invalid Texinfo syntax.
-                   (cut regexp-substitute/global #f "@" <> 'pre "@@" 'post)
-                   ;; Wrap camelCase or PascalCase words or text followed
-                   ;; immediately by "()" in @code{...}.
-                   (lambda (word)
-                     (let ((pattern
-                            (make-regexp
-                             "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z]|.+\\(\\))")))
-                       (match (list-matches pattern word)
-                         (() word)
-                         ((m . rest)
-                          ;; Do not include leading or trailing punctuation,
-                          ;; unless its "()".
-                          (let* ((last-text (if (string-suffix? "()" (match:substring m 1))
-                                                (string-length (match:substring m 1))
-                                                (or (and=> (string-skip-right word char-set:punctuation) 1+)
-                                                    (string-length word))))
-                                 (inner (substring word (match:start m) last-text))
-                                 (pre (string-take word (match:start m)))
-                                 (post (substring word last-text (string-length word))))
-                            (string-append pre "@code{" inner "}" post))))))))))
-         (words
-          (string-tokenize (string-trim-both description)
-                           (char-set-complement
-                            (char-set #\space #\newline))))
-         (new-words
-          (match words
-            (((and (or "A" "Classes" "Functions" "Methods" "Tools")
-                   first) . rest)
-             (cons* "This" "package" "provides"
-                    (string-downcase first) rest))
-            (((and (or "Contains"
-                       "Creates"
-                       "Performs"
-                       "Provides"
-                       "Produces"
-                       "Implements"
-                       "Infers") first) . rest)
-             (cons* "This" "package"
-                    (string-downcase first) rest))
-            (_ words)))
-         (new-words
-           (match new-words
-             ((rest ... last)
-              (reverse (cons (if (or (string-suffix? "." last)
-                                     (string-suffix? "!" last)
-                                     (string-suffix? "?" last))
-                               last
-                               (string-append last "."))
-                             (reverse rest))))))
-         (cleaned
-          (string-join (map fix-word new-words))))
-    ;; Use double spacing between sentences
-    (fill-paragraph (regexp-substitute/global #f "\\. \\b"
-                                              cleaned 'pre
-                                              (lambda (m)
-                                                (let ((pre (match:prefix m))
-                                                      (abbrevs '("Dr" "Mr" "Mrs"
-                                                                 "Ms" "Prof" "vs"
-                                                                 "e.g")))
-                                                  (if (and (> (string-length pre) 0)
-                                                           (or (any (cut string-suffix? <> pre) abbrevs)
-                                                               (char-upper-case?
-                                                                (string-ref pre (1- (string-length pre))))))
-                                                      ". "
-                                                      ".  ")))
-                                              'post)
-                    length)))
+  (if (or (not (string? description)) (string=? (string-trim-both description) ""))
+      (G_ "This package lacks a description.  Run \
+\"info '(guix) Synopses and Descriptions'\" for more information.")
+
+      (let* ((fix-word
+              (lambda (word)
+                (fold (lambda (proc acc) (proc acc)) word
+                      (list
+                       ;; Remove wrapping in single quotes, common in R packages.
+                       (cut string-trim-both <> #\')
+                       ;; Escape single @ to prevent it from being understood as
+                       ;; invalid Texinfo syntax.
+                       (cut regexp-substitute/global #f "@" <> 'pre "@@" 'post)
+                       ;; Wrap camelCase or PascalCase words or text followed
+                       ;; immediately by "()" in @code{...}.
+                       (lambda (word)
+                         (let ((pattern
+                                (make-regexp
+                                 "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z]|.+\\(\\))")))
+                           (match (list-matches pattern word)
+                             (() word)
+                             ((m . rest)
+                              ;; Do not include leading or trailing punctuation,
+                              ;; unless its "()".
+                              (let* ((last-text
+                                      (if (string-suffix? "()" (match:substring m 1))
+                                          (string-length (match:substring m 1))
+                                          (or (and=> (string-skip-right word char-set:punctuation) 1+)
+                                              (string-length word))))
+                                     (inner (substring word (match:start m) last-text))
+                                     (pre (string-take word (match:start m)))
+                                     (post (substring word last-text (string-length word))))
+                                (string-append pre "@code{" inner "}" post))))))))))
+             (words
+              (string-tokenize (string-trim-both description)
+                               (char-set-complement
+                                (char-set #\space #\newline))))
+             (new-words
+              (match words
+                (((and (or "A" "Classes" "Functions" "Methods" "Tools")
+                       first) . rest)
+                 (cons* "This" "package" "provides"
+                        (string-downcase first) rest))
+                (((and (or "Contains"
+                           "Creates"
+                           "Performs"
+                           "Provides"
+                           "Produces"
+                           "Implements"
+                           "Infers") first) . rest)
+                 (cons* "This" "package"
+                        (string-downcase first) rest))
+                (_ words)))
+             (new-words
+              (match new-words
+                ((rest ... last)
+                 (reverse (cons (if (or (string-suffix? "." last)
+                                        (string-suffix? "!" last)
+                                        (string-suffix? "?" last))
+                                    last
+                                    (string-append last "."))
+                                (reverse rest))))))
+             (cleaned
+              (string-join (map fix-word new-words))))
+        ;; Use double spacing between sentences
+        (fill-paragraph
+         (regexp-substitute/global #f "\\. \\b"
+                                   cleaned 'pre
+                                   (lambda (m)
+                                     (let ((pre (match:prefix m))
+                                           (abbrevs '("Dr" "Mr" "Mrs"
+                                                      "Ms" "Prof" "vs"
+                                                      "e.g")))
+                                       (if (and (> (string-length pre) 0)
+                                                (or (any (cut string-suffix? <> pre) abbrevs)
+                                                    (char-upper-case?
+                                                     (string-ref pre (1- (string-length pre))))))
+                                           ". "
+                                           ".  ")))
+                                   'post)
+         length))))
 
 (define (beautify-synopsis synopsis)
   "Improve the package SYNOPSIS."
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index 607349203c..27bd87940a 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -31,6 +31,16 @@ (define-module (test-import-utils)
 
 (test-begin "import-utils")
 
+(test-equal "beautify-description: empty string"
+  "This package lacks a description.  Run \
+\"info '(guix) Synopses and Descriptions'\" for more information."
+  (beautify-description ""))
+
+(test-equal "beautify-description: not a string"
+  "This package lacks a description.  Run \
+\"info '(guix) Synopses and Descriptions'\" for more information."
+  (beautify-description '()))
+
 (test-equal "beautify-description: use double spacing"
   "\
 Trust me Mr. Hendrix, M. Night Shyamalan et al.  \

base-commit: 3a8c20408f0078a580d27f74bc69b5a1069a003b
--
2.47.1





Acknowledgement sent to Morgan Smith <Morgan.J.Smith@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#75151; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.