Closed (fixed)
Project:
Pathauto
Version:
8.x-1.11
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Jun 2022 at 14:41 UTC
Updated:
30 Mar 2026 at 22:50 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
Abdullah Yassin commentedComment #3
Abdullah Yassin commentedComment #4
Abdullah Yassin commentedComment #6
rajab natshahComment #7
rajab natshahComment #8
ngkoutsaik commentedHello,
I tried to replicate this issue but I could not. I installed a clean version of pathauto. I created content using as title " " \ ` , . - _ : ; | { [ } ] + = * & % ^ $ # @ ! ~ ( ) ? < > / \".
Could you add some more info on how to recreate this? What title did you use, what settings etc?
Thanks
Comment #9
rajab natshahA re-role for the patch to work with Pathauto 1.11
Comment #10
igork96 commentedI tested this on the 8.x-1.11 version with Drupal 9.4.8 and can't reproduce it. Please give more info on how to reproduce this.
Comment #11
sweetchillyphily commentedHello,
Sorry first time posting here or doing something like this.
I have run into this problem in my production site, and was able to replicate the issue with confirmation that `preg_quote()` as suggested fixes it.
When saving my content type with these `$safe_tokens` it fails:
`alias|path|join-path|login-url|url|url-brief|?`
when removing the `?` from the safe tokens it works.
But I need the `?` so also adding `preg_quote()`, as suggested above, wrapped around safe_tokens works
Comment #14
mably commentedComment #15
mably commentedSummary
preg_match(): Compilation failed: range out of order in character classwhensafe_tokensconfig contains regex-special characters like?or-.Problem
In
AliasCleaner::cleanTokenValues(), thesafe_tokensconfig values were concatenated directly into a regex pattern without escaping. Characters like?(regex quantifier) or-(range operator in character classes) causedpreg_match()compilation errors.Fix
preg_quote()before building the regex alternation pattern. Also moved the config read andimplode()outside theforeachloop to avoid redundant calls on every iteration.Test coverage
testCleanTokenValuesWithRegexSpecialChars()kernel test that adds?to thesafe_tokensconfig and callscleanTokenValues(). A custom error handler captures anypreg_match()warnings and the test asserts none were triggered. Verified that the test fails without the fix and passes with it.Comment #16
berdirComment #17
mably commentedSuggested fixes have been implemented.
Comment #18
berdirComment #20
mably commented