Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Controller/Views/CattoolController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project_name is consumed by the Cattool frontend both for display (FilesMenu/label) and as a URL path segment when building /revise/${projectName}/... and /translate/${projectName}/... links. Slugifying it here will change the user-visible project name in the Cattool header (e.g., spaces/accents removed and lowercased). Consider keeping the original name for UI (e.g., project_display_name) and passing a separate sanitized slug field (e.g., project_slug) for URL building.

Suggested change
'project_name' => Utils::friendlySlug($chunkStruct->getProject()->name),
'project_name' => $chunkStruct->getProject()->name,
'project_slug' => Utils::friendlySlug($chunkStruct->getProject()->name),

Copilot uses AI. Check for mistakes.
'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(
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/Utils/Tools/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
// =========================================================================
Expand Down
Loading