diff --git a/lib/Controller/Views/CattoolController.php b/lib/Controller/Views/CattoolController.php index c67468311b..45b8c43f80 100644 --- a/lib/Controller/Views/CattoolController.php +++ b/lib/Controller/Views/CattoolController.php @@ -186,7 +186,7 @@ public function renderView(): void 'pageTitle' => $this->buildPageTitle($revisionNumber, $chunkStruct), 'password' => $chunkStruct->password, 'project' => $chunkStruct->getProject(), - 'project_name' => $chunkStruct->getProject()->name, + 'project_name' => Utils::friendlySlug($chunkStruct->getProject()->name), 'quality_report_href' => AppConfig::$BASEURL . "revise-summary/$chunkStruct->id-$chunkStruct->password", 'review_extended' => new PHPTalBoolean(true), 'review_password' => $isRevision ? $chunkReviewStruct->review_password : (new ChunkReviewDao())->findChunkReviewsForSourcePage( diff --git a/tests/unit/Utils/Tools/UtilsTest.php b/tests/unit/Utils/Tools/UtilsTest.php index 6588659c35..952f801968 100644 --- a/tests/unit/Utils/Tools/UtilsTest.php +++ b/tests/unit/Utils/Tools/UtilsTest.php @@ -241,6 +241,45 @@ public function testFriendlySlugRemovesSpecialCharacters(): void $this->assertMatchesRegularExpression('/^[a-z0-9\-]+$/', $result); } + #[Test] + public function testFriendlySlugReturnsHyphenForEmptyStringInput(): void + { + $result = Utils::friendlySlug(''); + $this->assertEquals('-', $result); + } + + #[Test] + public function testFriendlySlugHandlesValidAsciiSymbol(): void + { + $result = Utils::friendlySlug('hello-world'); + $this->assertEquals('hello-world', $result); + } + + #[Test] + public function testFriendlySlugStripsLogicalNegationSymbol(): void + { + $result = Utils::friendlySlug('hello¬world'); + $this->assertMatchesRegularExpression('/^[a-z0-9\-]+$/', $result); + $this->assertStringNotContainsString('¬', $result); + } + + #[Test] + public function testFriendlySlugStripsBoxDrawingCharacter(): void + { + $result = Utils::friendlySlug('╚══test══╝'); + $this->assertMatchesRegularExpression('/^[a-z0-9\-]+$/', $result); + $this->assertStringNotContainsString('╚', $result); + $this->assertStringNotContainsString('═', $result); + } + + #[Test] + public function testFriendlySlugStripsBlockGraphicSymbol(): void + { + $result = Utils::friendlySlug('hello░world'); + $this->assertMatchesRegularExpression('/^[a-z0-9\-]+$/', $result); + $this->assertStringNotContainsString('░', $result); + } + // ========================================================================= // Tests for replace_accents() // =========================================================================