Skip to content

[String] Slugger should only replace special characters for the English locale #36383

@javiereguiluz

Description

@javiereguiluz

Symfony version(s) affected: 5.0+

Description
The Slugger provided by String replaces & by and and @ by at. This is only correct for English, but it looks like it's doing it unconditionally. See

->replace('@', $separator.'at'.$separator)
->replace('&', $separator.'and'.$separator)

Possible solution
Do this replacement only for English. If it's not possible to detect the locale, then it's preferable to not do the replacement.

Additional context
This was originally reported in this comment of the Symfony blog.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions