Project

General

Profile

Actions

Bug #94693

closed

Slug fieldSeparator (and replacements) replaced by fallbackCharacter

Added by Oliver N. over 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2021-08-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Example 1:

'config' => [
    'type' => 'slug',
    'generatorOptions' => [
        'fields' => ['field1','field2'],
        'fieldSeparator' => '-',
    ],
    'fallbackCharacter' => '.',
    'eval' => 'uniqueInSite'
],

Input field1    : Field-1
Input field2    : Field-2
Expected result : field.1-field.2
Generated result: field.1.field.2

Example 2:

'config' => [
    'type' => 'slug',
    'generatorOptions' => [
        'fields' => ['field1','field2'],
        'fieldSeparator' => '-',
        'replacements' => [
            '-' => '_'
        ],
    ],
    'fallbackCharacter' => '.',
    'eval' => 'uniqueInSite'
],

Input field1    : Field-1
Input field2    : Field-2
Expected result : field_1-field_2
Generated result: field.1.field.2

Function SlugHelper::sanitize is called in the end of the generate function leads into to this result.
The "magic" seems to happen in the code below - and showing which characters are affected.

// Convert some special tokens (space, "_" and "-") to the space character
$fallbackCharacter = (string)($this->configuration['fallbackCharacter'] ??
$slug = preg_replace('/[ \t\x{00A0}\-+_]+/u', $fallbackCharacter, $slug);
...
// Get rid of all invalid characters, but allow slashes
$slug = preg_replace('/[^\p{L}\p{M}0-9\/' . preg_quote($fallbackCharacter) . ']/u', '', $slug);

Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Feature #94162: Update Slughelper to allow both dash and lodash CharactersUnder Review2021-05-19

Actions
Actions

Also available in: Atom PDF