emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#53548: closed ([PATCH] Harden beautify-description)


From: GNU bug Tracking System
Subject: bug#53548: closed ([PATCH] Harden beautify-description)
Date: Tue, 08 Feb 2022 09:53:02 +0000

Your message dated Tue, 08 Feb 2022 10:51:51 +0100
with message-id <87sfstbs94.fsf@gnu.org>
and subject line Re: bug#53548: [PATCH] Harden beautify-description
has caused the debbugs.gnu.org bug report #53548,
regarding [PATCH] Harden beautify-description
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
53548: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=53548
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] Harden beautify-description Date: Wed, 26 Jan 2022 10:41:39 +0100
Hi all,

Missing metadata in packages used to break their imports, at least for
opam packages, until this was fixed by Julien in
24aa7b3c21309b63cc6e8e18d6417d2cddccf6c6. When Xinglu improved the
output of descriptions in 155fc235b5e1b41b4665c782365dd2bf11beae9c, it
made the imports break again in the case when the `description` field
is missing and Julien's fix applies, returning #f in `metadata-ref`
instead of crashing. Trouble is: beautify-description expects its
description argument to be a string and will crash if this assumption
isn't met (when calling the `string-prefix?` predicate).

This patch hopes to fix this by prepending a catch-all case in
`beautify-description` to intercept all calls to it without a proper
string as description. In addition, since I had to search for
beautify-description in all the code base I made its import from
opam.scm explicit, to carry on what I think is a good practice which I
would like to see progressively enforced in guix' source code: explicit
imports everywhere, to prevent accidental namespace collisions and to
ease source code browsing by pointing out where everything comes from
in a given source file.

This patch can probably not be pushed as-is and should be improved
first:

- In the generated description, I think it'd be useful to point the
  user to the documentation page helping them to understand what is
  expected in a good description, so I generated a link to it on the
  web-hosted manual. However, this choice is arbitrary: why not an
  info page or the PDF ? Is there an consensus on how to refer to a
  page in the documentation in guix's output ? If not and we stick to
  the web, perhaps the `home-url` and `doc-path` variable could be
  declared outside of (guix import utils), perhaps turned into
  functions and localized to the user's preference instead of the
  built-in english version I used.

- If all-explict use-modules policy is relevant, it should be applied
  to the other import modules that Xinglu edited in 155fc23. If not,
  then my change in guix/import/opam.scm should perhaps not be applied
  at all.

Thanks for your feedback on this proposal !

Best regards,

Alice

Attachment: 0001-guix-import-Harden-beautify-description.patch
Description: Text Data


--- End Message ---
--- Begin Message --- Subject: Re: bug#53548: [PATCH] Harden beautify-description Date: Tue, 08 Feb 2022 10:51:51 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Hi!

Alice BRENON <alice.brenon@ens-lyon.fr> skribis:

> From cfb57a40a90bfc31d1b846f3e981469285f1bd7b Mon Sep 17 00:00:00 2001
> From: Alice BRENON <alice.brenon@ens-lyon.fr>
> Date: Wed, 26 Jan 2022 09:27:12 +0100
> Subject: [PATCH] guix: import: Harden beautify-description.
>
> * guix/import/utils.scm (beautify-description): Handle non-string
> arguments.
> [use-modules]: Explicitly import G_ from (guix i18n) and make (guix ui)
> import explicit.
> * guix/import/opam.scm: [use-modules] Make imports explicit for module
> (guix import utils).

Applied.

I removed extra space from the message, as shown below.

Thanks!

Ludo’.

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 934b224bec..9cadbb3d5f 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -244,8 +244,8 @@ (define* (beautify-description description #:optional 
(length 80))
 LENGTH characters."
   (let ((cleaned (cond
                   ((not (string? description))
-                   (G_ "This package lacks a description.  Run \"info '(guix)
-                       Synopses and Descriptions'\" for more information."))
+                   (G_ "This package lacks a description.  Run \
+\"info '(guix) Synopses and Descriptions'\" for more information."))
                   ((string-prefix? "A " description)
                    (string-append "This package provides a"
                                   (substring description 1)))

--- End Message ---

reply via email to

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