GNU bug report logs - #70494
[PATCH 00/23] Groundwork for the Guile guix-daemon

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sun, 21 Apr 2024 09:37:01 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: Christopher Baines <mail <at> cbaines.net>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, 70494 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>, Tobias Geerinckx-Rice <me <at> tobias.gr>, Ricardo Wurmus <rekado <at> elephly.net>, Christopher Baines <guix <at> cbaines.net>
Subject: [bug#70494] [PATCH 09/23] store: Add validate-store-name.
Date: Mon, 13 May 2024 18:04:14 +0200
Christopher Baines <mail <at> cbaines.net> skribis:

> * guix/store.scm (validate-store-name): New procedure.
>
> Change-Id: I507d070d1cfdbd433d93830ee2937b1a1dee315a
> ---
>  guix/store.scm | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/guix/store.scm b/guix/store.scm
> index b83f205096..096efcd128 100644
> --- a/guix/store.scm
> +++ b/guix/store.scm
> @@ -205,6 +205,7 @@ (define-module (guix store)
>              store-path-package-name
>              store-path-hash-part
>              direct-store-path
> +            validate-store-name
>              derivation-log-file
>              log-file))
>  
> @@ -2303,6 +2304,16 @@ (define (store-path? path)
>    ;; `isStorePath' in Nix does something similar.
>    (string-prefix? (%store-prefix) path))
>  
> +(define (validate-store-name name)
> +  (string-for-each
> +   (lambda (c)
> +     (unless (or (char-alphabetic? c)
> +                 (char-numeric? c)
> +                 (member c '(#\+ #\- #\. #\_ #\? #\=)))
> +       (error (simple-format #f "invalid character ~A" c))))
> +   name)
> +  #t)

This is not the same as ‘checkStoreName’ in store-api.cc, due to Unicode
support.

So I think you have to specify the complete alphabet like
‘ensure-valid-store-file-name’ in (guix scripts download) does.

Also, distinguish ‘valid-store-name?’ from ‘validate-store-name’.

Raise a dedicated SRFI-35 error condition or use ‘formatted-message’; as
a rule of thumb, never use ‘error’ because it cannot be usefully handled
by callers.

Ludo’.




This bug report was last modified 1 year and 28 days ago.

Previous Next


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