unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Hartmut Goebel <h.goebel@crazy-compilers.com>
Cc: 36976@debbugs.gnu.org
Subject: [bug#36976] [PATCH 1/1] download: Map file-name characters not allowed in store.
Date: Fri, 23 Aug 2019 23:08:29 +0200	[thread overview]
Message-ID: <874l271tf6.fsf@gnu.org> (raw)
In-Reply-To: <20190808144448.25147-1-h.goebel@crazy-compilers.com> (Hartmut Goebel's message of "Thu, 8 Aug 2019 16:44:48 +0200")

Hello,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> In the file-name to be used for storing into the store, replace any
> character not allowed in the store-file-name by an underscore.
> This is only done when NAME is not given and thus defaults to
> toe URL's basename. If NAME is given, this is used unchanged,
> allowing for more control by other functions.
>
> Fixes <http://issues.guix.gnu.org/issue/26175>
>
> * guix/download.scm (safe-name): New function.
>   (download-to-store): NAME defaults to the "safe" basename of URL.

What about moving this automatic renaming feature to (guix scripts
download)?  I’d rather not do it in the core APIs.

> +(define (safe-name name)
> +  "Replace any character not allowed in a stroe name by an underscore."
                                               ^^
Typo.

I’d call it ‘ensure-valid-store-file-name’ or similar, WDYT?

> +  (define valid-characters
> +    ;; according to nix/libstore/store-api.cc
> +    (string->list (string-append "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> +                                 "abcdefghijklmnopqrstuvwxyz"
> +                                 "0123456789" "+-._?=")))
> +  (string-map (lambda (c)
> +                (if (member c valid-characters) c #\_))
> +              name))

Instead of a list, please use a SRFI-14 “character set”, like this:

  (define valid
    (string->char-set …))

  (string-map (lambda (c)
                (if (char-set-contains? valid c) …))
              name)

Thanks,
Ludo’.

  reply	other threads:[~2019-08-23 21:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 14:44 [bug#36976] [PATCH 1/1] download: Map file-name characters not allowed in store Hartmut Goebel
2019-08-23 21:08 ` Ludovic Courtès [this message]
2019-08-27  7:53   ` Hartmut Goebel
2019-09-01 19:39     ` Ludovic Courtès
2019-09-26 15:50       ` bug#36976: " Hartmut Goebel
2019-09-03 16:20 ` [bug#36976] [Patch v2] guix download: Ensure destination file-name is valid in the store Hartmut Goebel

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=874l271tf6.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=36976@debbugs.gnu.org \
    --cc=h.goebel@crazy-compilers.com \
    /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).