You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On line 813 of Stringify.php there is a function called slugify(). I had to add an escape character in the regex pattern on the dash or hyphen to prevent the error message. I'm not sure if that hyphen was intended to be unescaped. I made the following change to that function to prevent the error and allow the pages to load correctly.
Apparently the hyphen needs to be either the first or last character in the pattern, or escaped: invalid range in character class
public function slugify($replacement = '-')
{
$stringy = $this->toAscii();
$quotedReplacement = preg_quote($replacement);
// $pattern = "/[^a-zA-Z\d\s-_$quotedReplacement]/u"; // Commented this out.
$pattern = "/[^a-zA-Z\d\s\-_$quotedReplacement]/u"; // Added backslash in front of the hyphen.
$stringy->str = preg_replace($pattern, '', $stringy);
With PHP 7.3 it is necessary to escape - when used in character classes but not as range.
So this is the corrected line: $pattern = "/[^a-zA-Z\\d\\s\\-_$quotedReplacement]/u";
The error actually happen because the preg_replace in line 1174 actually replaces all characters in the stringy with '' because of the wrong regex pattern you mentioned.
This is preventing our application to go to production, is there anyway we can help you fix this or make a release with the fix get published faster?
On line 813 of Stringify.php there is a function called slugify(). I had to add an escape character in the regex pattern on the dash or hyphen to prevent the error message. I'm not sure if that hyphen was intended to be unescaped. I made the following change to that function to prevent the error and allow the pages to load correctly.
Apparently the hyphen needs to be either the first or last character in the pattern, or escaped: invalid range in character class
public function slugify($replacement = '-')
{
$stringy = $this->toAscii();
// $pattern = "/[^a-zA-Z\d\s-_$quotedReplacement]/u"; // Commented this out.
$pattern = "/[^a-zA-Z\d\s\-_$quotedReplacement]/u"; // Added backslash in front of the hyphen.
$stringy->str = preg_replace($pattern, '', $stringy);
The text was updated successfully, but these errors were encountered: