From 652e0c9110cae669767318dac7c09bcd4f56ce75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 8 Jun 2026 11:02:59 +0200 Subject: =?UTF-8?q?store:=20Add=20=E2=80=98valid-path-syntax=3F=E2=80=99?= =?UTF-8?q?=20and=20=E2=80=98valid-store-name=3F=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/store.scm (store-path?): Update docstring. (%store-item-charset): New variable. (valid-store-name?, valid-path-basename-syntax?, valid-path-syntax?): New procedures. * tests/store.scm ("valid-path-syntax?") ("valid-path-syntax? truncated hash") ("valid-path-syntax? slash") ("valid-path-syntax? leading dot") ("valid-path-syntax? prefix") ("valid-path-syntax? truncated"): New tests. Change-Id: Ic808dd5a8270fbea20e9c99c2861f30133d13b41 Signed-off-by: Ludovic Courtès --- tests/store.scm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/store.scm b/tests/store.scm index 87773bf0c36..e7ba7469047 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -78,6 +78,30 @@ (open-connection #f #:port port) 'broken))) +(test-assert "valid-path-syntax?" + (valid-path-syntax? (string-append (%store-prefix) + "/yp8mg1rwaw3y1p09bc8dx4l6rx4qx961-coreutils-9.1"))) + +(test-assert "valid-path-syntax? truncated hash" + (not (valid-path-syntax? + (string-append (%store-prefix) + "/p8mg1rwaw3y1p09bc8dx4l6rx4qx961-coreutils-9.1")))) + +(test-assert "valid-path-syntax? slash" + (not (valid-path-syntax? + (string-append (%store-prefix) + "/yp8mg1rwaw3y1p09bc8dx4l6rx4qx961-coreutils-9.1/../../../etc/passwd")))) + +(test-assert "valid-path-syntax? leading dot" + (not (valid-path-syntax? (string-append (%store-prefix) + "/yp8mg1rwaw3y1p09bc8dx4l6rx4qx961-.leading-dot")))) + +(test-assert "valid-path-syntax? prefix" + (not (valid-path-syntax? (%store-prefix)))) + +(test-assert "valid-path-syntax? truncated" + (not (valid-path-syntax? (string-append (%store-prefix) "/aaaaaaaaaaa")))) + (test-equal "store-path-hash-part" "283gqy39v3g9dxjy26rynl0zls82fmcg" (store-path-hash-part -- cgit v1.2.3