Bug #94693

Slug fieldSeparator (and replacements) replaced by fallbackCharacter

Added by Oliver Niehaus 3 months ago. Updated 2 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & 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);
#1

Updated by Oliver Niehaus 3 months ago

  • Category set to Link Handling, Site Handling & Routing
#2

Updated by Stefan Busemann 2 months ago

possible duplication of #94162

Also available in: Atom PDF