From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id EBf6OFA6QmbQCgEAe85BDQ:P1 (envelope-from ) for ; Mon, 13 May 2024 18:05:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id EBf6OFA6QmbQCgEAe85BDQ (envelope-from ) for ; Mon, 13 May 2024 18:05:37 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=El0NzFOn; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715616336; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=NUny8JBV80qNzi4rg54TBUoo+FeLT2Ie6FE948WM+OE=; b=jdwVXh0PM/OYyXPSTGZb35grIu3/Wd1jHf/rDoUGXmKX/E/92Lxh/7lKbtNT4YWqi8Mu3T NEw7GC+4JvajpWS4hRwHbnqO3O4VguwgGdFGJkB8BmDaGPboqni0oZiGLf2ZpLoSgVGP/U /rLxt7X1p7VSuCeDmek2yTSFVwgKAwZo4RGoMdgPbYsewTtoNO9OvzQYuIkc3oHoXNpbf5 xKKez3j2u7aVAcgmNbWAhv2WpAQEvxwTNRRo2lLQQ4hsxTqKyIjo3bXi8vrMC1NGlY9PeO PtGvhPeqWuWqCh6m+1pkLjYScc9S35ZCyi7e2Zp2EL6Q2dZmegXzXaojHiIb2g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=El0NzFOn; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715616336; a=rsa-sha256; cv=none; b=pBaZkuROIjiyPNu1aKbYt5Y1hvpXRcwhe6MQD8o72a4zMelWgAgO+Y58MocPZn9u/btnya XVBDI7ZzPUriQ2LuhAh4twTVoDNR8/G6xLmKhSSuKC9qAQEO4wcb+o/nAGBjBhyUufjikW lAOPQQhoTS7dAa2LSIBouH1szxX4Wrh1XajQsPhWNb74oAg952mQOrq/HTOaMUYfSRyH4q F8ILGYobzoHPswnPrk1Ncn/755KGVSfBT1P2QuEkb51xQuvNmdbzfOQE4VRmEhC7WJD9eB 3NQMXVXk1YlkP5hHlevBXxzMcs2YpL95+0FjT0o+JtXc45uyn5CEDrfOhm1ALA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C544577001 for ; Mon, 13 May 2024 18:05:36 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6YAq-0003w2-MC; Mon, 13 May 2024 12:05:14 -0400 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 ) id 1s6YAg-0003vc-AG for guix-patches@gnu.org; Mon, 13 May 2024 12:05:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6YAf-0003Lu-UT for guix-patches@gnu.org; Mon, 13 May 2024 12:05:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s6YAg-0003Ef-2T for guix-patches@gnu.org; Mon, 13 May 2024 12:05:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70494] [PATCH 09/23] store: Add validate-store-name. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 13 May 2024 16:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70494 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: Josselin Poiret , 70494@debbugs.gnu.org, Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , Ricardo Wurmus , Christopher Baines Received: via spool by 70494-submit@debbugs.gnu.org id=B70494.171561627012406 (code B ref 70494); Mon, 13 May 2024 16:05:02 +0000 Received: (at 70494) by debbugs.gnu.org; 13 May 2024 16:04:30 +0000 Received: from localhost ([127.0.0.1]:33501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6YAA-0003E2-D5 for submit@debbugs.gnu.org; Mon, 13 May 2024 12:04:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6YA5-0003Dp-IO for 70494@debbugs.gnu.org; Mon, 13 May 2024 12:04:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s6Y9y-0003Gl-3j; Mon, 13 May 2024 12:04:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=NUny8JBV80qNzi4rg54TBUoo+FeLT2Ie6FE948WM+OE=; b=El0NzFOnrUJ1jHTaFlTb fNV05utBia4UBXmxECgQ6wkYrsAHCEu6beKWva+nDmwv1Y2EKbnX8AJKX6K8pbmS3+GtYO0XJbUDI xSLsM4hllWPKkTKW8atjbigE8Fhsoxg9HlXsxDKjv+NKEl5y5pJcCcfAg6S1bnMJx+m8ALGGmRYNK Dzle9KCke+RCDZVwlUD5MjuXxA72h0rmxErnNRYYTjLBOm9dWztNxfVr72VZKOwKi6JsgB0Q83yNC tFRFhLaxGiSCAVzEo4MiUwQQSOaSsdWcnSOn64qIXbnXq6ISZDsTxB2jjTm7spr8CNqMK0ByT9TQ7 Scqox+2gjJCtAA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <803b6bbff7d1cad61eff5b9f8c18007af53de436.1713692561.git.mail@cbaines.net> (Christopher Baines's message of "Sun, 21 Apr 2024 10:42:27 +0100") References: <87bk632h36.fsf@cbaines.net> <803b6bbff7d1cad61eff5b9f8c18007af53de436.1713692561.git.mail@cbaines.net> Date: Mon, 13 May 2024 18:04:14 +0200 Message-ID: <87y18d7l6p.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -5.77 X-Migadu-Queue-Id: C544577001 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -5.77 X-TUID: CTfp6sG+D2uM Christopher Baines 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)) >=20=20 > @@ -2303,6 +2304,16 @@ (define (store-path? path) > ;; `isStorePath' in Nix does something similar. > (string-prefix? (%store-prefix) path)) >=20=20 > +(define (validate-store-name name) > + (string-for-each > + (lambda (c) > + (unless (or (char-alphabetic? c) > + (char-numeric? c) > + (member c '(#\+ #\- #\. #\_ #\? #\=3D))) > + (error (simple-format #f "invalid character ~A" c)))) > + name) > + #t) This is not the same as =E2=80=98checkStoreName=E2=80=99 in store-api.cc, d= ue to Unicode support. So I think you have to specify the complete alphabet like =E2=80=98ensure-valid-store-file-name=E2=80=99 in (guix scripts download) d= oes. Also, distinguish =E2=80=98valid-store-name?=E2=80=99 from =E2=80=98validat= e-store-name=E2=80=99. Raise a dedicated SRFI-35 error condition or use =E2=80=98formatted-message= =E2=80=99; as a rule of thumb, never use =E2=80=98error=E2=80=99 because it cannot be use= fully handled by callers. Ludo=E2=80=99.