From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 23 17:08:39 2019 Received: (at 36976) by debbugs.gnu.org; 23 Aug 2019 21:08:39 +0000 Received: from localhost ([127.0.0.1]:41312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1GnW-0003KA-R6 for submit@debbugs.gnu.org; Fri, 23 Aug 2019 17:08:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1GnV-0003Jw-7b for 36976@debbugs.gnu.org; Fri, 23 Aug 2019 17:08:37 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i1GnP-0004vh-PC; Fri, 23 Aug 2019 17:08:31 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=52766 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1i1GnP-0000i2-BV; Fri, 23 Aug 2019 17:08:31 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Hartmut Goebel Subject: Re: [bug#36976] [PATCH 1/1] download: Map file-name characters not allowed in store. References: <20190808144448.25147-1-h.goebel@crazy-compilers.com> Date: Fri, 23 Aug 2019 23:08:29 +0200 In-Reply-To: <20190808144448.25147-1-h.goebel@crazy-compilers.com> (Hartmut Goebel's message of "Thu, 8 Aug 2019 16:44:48 +0200") Message-ID: <874l271tf6.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 36976 Cc: 36976@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, Hartmut Goebel 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 > > * 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=E2=80=99d 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=E2=80=99d call it =E2=80=98ensure-valid-store-file-name=E2=80=99 or simil= ar, WDYT? > + (define valid-characters > + ;; according to nix/libstore/store-api.cc > + (string->list (string-append "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > + "abcdefghijklmnopqrstuvwxyz" > + "0123456789" "+-._?=3D"))) > + (string-map (lambda (c) > + (if (member c valid-characters) c #\_)) > + name)) Instead of a list, please use a SRFI-14 =E2=80=9Ccharacter set=E2=80=9D, li= ke this: (define valid (string->char-set =E2=80=A6)) (string-map (lambda (c) (if (char-set-contains? valid c) =E2=80=A6)) name) Thanks, Ludo=E2=80=99.