File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 1414use function in_array ;
1515use function sprintf ;
1616use function str_starts_with ;
17- use function stripos ;
1817use function strlen ;
1918use function strpos ;
2019use function strtolower ;
@@ -128,18 +127,18 @@ private function validatePattern(string $pattern): ?string
128127 try {
129128 Strings::match ('' , $ pattern );
130129 } catch (RegexpException $ e ) {
131- if (
132- stripos ($ e ->getMessage (), 'Compilation failed ' ) !== false
133- && stripos ($ e ->getMessage (), 'UTF-8 ' ) !== false
134- ) {
135- $ patternPos = strpos ($ e ->getMessage (), 'pattern: ' );
130+ $ invalidPatternMessage = $ e ->getMessage ();
131+ try {
132+ Strings::match ($ invalidPatternMessage , '//u ' );
133+ return $ invalidPatternMessage ;
134+ } catch (RegexpException ) {
135+ $ patternPos = strpos ($ invalidPatternMessage , 'pattern: ' );
136136 if ($ patternPos === false ) {
137137 throw new ShouldNotHappenException ();
138138 }
139139 // strip invalid utf-8 pattern contents to keep the error message NEON parsable.
140- return substr ($ e -> getMessage () , 0 , $ patternPos + strlen ('pattern: ' ) - 1 );
140+ return substr ($ invalidPatternMessage , 0 , $ patternPos + strlen ('pattern: ' ) - 1 );
141141 }
142- return $ e ->getMessage ();
143142 }
144143
145144 return null ;
You can’t perform that action at this time.
0 commit comments