From 2397a35d0e9a837e13812f80913f252086087054 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 9 Apr 2026 14:25:14 +0200 Subject: [PATCH 1/2] prevent generating paths with 2 slashes --- fixtures/Path.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fixtures/Path.php b/fixtures/Path.php index de15e0d..6b60115 100644 --- a/fixtures/Path.php +++ b/fixtures/Path.php @@ -31,8 +31,8 @@ public static function directories(): Set */ private static function strings(): Set { - return Set::strings()->filter( - static fn($value) => (bool) \preg_match('~\S+~', $value), - ); + return Set::strings() + ->filter(static fn($value) => (bool) \preg_match('~\S+~', $value)) + ->exclude(static fn($value) => \str_contains($value, '//')); } } From 72d4ef0d508d7de5802325c126f39223da4c06e7 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 9 Apr 2026 14:40:38 +0200 Subject: [PATCH 2/2] prevent generating relative paths starting with a backslash --- fixtures/Path.php | 3 ++- tests/PathTest.php | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fixtures/Path.php b/fixtures/Path.php index 6b60115..8f9afa1 100644 --- a/fixtures/Path.php +++ b/fixtures/Path.php @@ -33,6 +33,7 @@ private static function strings(): Set { return Set::strings() ->filter(static fn($value) => (bool) \preg_match('~\S+~', $value)) - ->exclude(static fn($value) => \str_contains($value, '//')); + ->exclude(static fn($value) => \str_contains($value, '//')) + ->exclude(static fn($value) => \str_starts_with($value, '\\')); } } diff --git a/tests/PathTest.php b/tests/PathTest.php index 01551a2..7dfd97e 100644 --- a/tests/PathTest.php +++ b/tests/PathTest.php @@ -110,6 +110,13 @@ public function testResolveAbsolutility(): BlackBox\Proof }); } + public function testPathStartingWithBackslashIsInvalid() + { + $this->assert()->throws( + static fn() => Path::of('\\\\'), + ); + } + public static function resolutions(): array { return [