🐛 fix: apply friendlySlug to project_name in CattoolController config#4549
🐛 fix: apply friendlySlug to project_name in CattoolController config#4549
Conversation
## Summary Apply Utils::friendlySlug() to project_name in CattoolController view params, ensuring the slug used in the cattool config is sanitized consistently. Add edge case tests for friendlySlug() (empty string, ASCII symbol, extended ASCII graphic characters). ## Type - [x] `fix` — bug fix - [x] `test` — test coverage ## Changes | File | Change | |------|--------| | lib/Controller/Views/CattoolController.php | Wrap project name with Utils::friendlySlug() | | tests/unit/Utils/Tools/UtilsTest.php | Add edge case tests: empty string, valid ASCII symbol, graphic chars (¬, ╚, ═, ░) | ## Testing - [x] New tests added for changed behavior - [x] phpstan: no new errors introduced ## AI Disclosure - [x] AI tools were used — GitHub Copilot (claude-sonnet-4-20250514)
There was a problem hiding this comment.
Pull request overview
This PR sanitizes the project_name value emitted in the Cattool view config by applying Utils::friendlySlug(), and extends unit coverage for friendlySlug() edge cases.
Changes:
- Slugify
project_nameinCattoolControllerto ensure the Cattool config uses a consistently sanitized value. - Add unit tests covering
friendlySlug()edge inputs (empty string, hyphenated ASCII, and extended graphic characters).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/Controller/Views/CattoolController.php | Applies Utils::friendlySlug() to the project name before injecting it into Cattool view params/config. |
| tests/unit/Utils/Tools/UtilsTest.php | Adds additional friendlySlug() edge case tests to validate sanitization behavior. |
| 'password' => $chunkStruct->password, | ||
| 'project' => $chunkStruct->getProject(), | ||
| 'project_name' => $chunkStruct->getProject()->name, | ||
| 'project_name' => Utils::friendlySlug($chunkStruct->getProject()->name), |
There was a problem hiding this comment.
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.
| 'project_name' => Utils::friendlySlug($chunkStruct->getProject()->name), | |
| 'project_name' => $chunkStruct->getProject()->name, | |
| 'project_slug' => Utils::friendlySlug($chunkStruct->getProject()->name), |
🧪 Test-Guard Report✅ PASS — All changed source files have adequate test coverage. Coverage Analysis: ❌ FAILNo changed source files found in coverage report (threshold: 80%)
Test File Matching: ❌ FAILFile matching: 1 fail
Per-File Evaluation: ✅ PASSEvaluated 1 files: 1 via AI (1 batch), 0 via shortcuts.
Result: ✅ PASS |
Summary
Apply Utils::friendlySlug() to project_name in CattoolController view params,
ensuring the slug used in the cattool config is sanitized consistently.
Add edge case tests for friendlySlug() (empty string, ASCII symbol, extended
ASCII graphic characters).
Type
Changes
Testing
AI Disclosure