Skip to content
Snippets Groups Projects
Commit 383846c6 authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[BUGFIX] Do not remove trailing slash in slug sanitization

It is totally legitimate to allow /my-page/ as slug (when in FormEngine
just remove the "readonly" attribute of the slug field), if explicitly
wanted.

There is a difference between "generate" (automatically create the slug)
where TYPO3 recommends slugs without slashes, and "sanitize"
to clean up a slug, where "/" is completely valid.

Resolves: #86055
Releases: master
Change-Id: I8e73f27e18fc74242cb230d69a85ec2946cf1dae
Reviewed-on: https://review.typo3.org/58099


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarFrans Saris <franssaris@gmail.com>
Tested-by: default avatarFrans Saris <franssaris@gmail.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 345c37af
Branches
Tags
No related merge requests found
......@@ -107,8 +107,9 @@ class SlugHelper
$slug = rawurlencode($slug);
// @todo: add a test and see if we need this
$slug = str_replace('%2F', '/', $slug);
// Remove trailing and beginning slashes
$slug = '/' . $this->extract($slug);
// Remove trailing and beginning slashes, except if the trailing slash was added, then we'll re-add it
$appendTrailingSlash = substr($slug, -1) === '/';
$slug = '/' . $this->extract($slug) . ($appendTrailingSlash ? '/' : '');
return $slug;
}
......
......@@ -80,20 +80,20 @@ class SlugHelperTest extends UnitTestCase
'/1/2',
'/1/2',
],
'remove trailing slash' => [
'do not remove trailing slash' => [
[],
'1/2/',
'/1/2',
'/1/2/',
],
'keep pending slash and remove fallback' => [
[],
'/-1/2',
'/1/2',
],
'remove trailing slash and fallback' => [
'do not remove trailing slash, but remove fallback' => [
[],
'1/2-/',
'/1/2',
'/1/2/',
],
'reduce multiple fallback chars to one' => [
[],
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment