Commit 8014aab4 authored by Micheal Mand's avatar Micheal Mand

It is suggested that the delimiter is passed to preg_quote

Just so it can handle escaping properly. Although, I don’t think that really matters in this case since exclamation marks are not valid in function names.
parent 6142f80f
......@@ -166,16 +166,16 @@ trait TaggableTrait
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
$name = preg_replace('!['.preg_quote($flip).']+!u', $separator, $name);
$name = preg_replace('![' . preg_quote($flip, '!') . ']+!u', $separator, $name);
// Replace @ with the word 'at'
$name = str_replace('@', $separator.'at'.$separator, $name);
$name = str_replace('@', $separator . 'at' . $separator, $name);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$name = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($name));
$name = preg_replace('![^' . preg_quote($separator, '!') . '\pL\pN\s]+!u', '', mb_strtolower($name));
// Replace all separator characters and whitespace by a single separator
$name = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $name);
$name = preg_replace('![' . preg_quote($separator, '!') . '\s]+!u', $separator, $name);
return trim($name, $separator);
}
......
Markdown is supported
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