File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
tests/unit/Codeception/Util Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -130,10 +130,10 @@ protected function typeComparison($data, $jsonType)
130130 continue ;
131131 }
132132
133- $ regexMatcher = '/:regex\(((.) .*?\2 )\)/ ' ;
133+ $ regexMatcher = '/:regex\((((\()|(\{)|(\[)|(<)|(.)) .*?(?(3)\)|(?(4)\}|(?(5)\]|(?(6)>|\7)))) )\)/ ' ;
134134 $ regexes = [];
135135
136- // Match the string ':regex(' and any characters until a regex delimiter (matches 99.999% use cases) followed by character ')'
136+ // Match the string ':regex(' and any characters until a ending regex delimiter followed by character ')'
137137 // Place the 'any character' + delimiter matches in to an array.
138138 preg_match_all ($ regexMatcher , $ type , $ regexes );
139139
Original file line number Diff line number Diff line change @@ -239,4 +239,14 @@ public function testRegexFilterWithPostfixedAlternatives()
239239 // currently produces a false negative
240240 $ this ->assertTrue ($ jsonType ->matches (['test ' => 'string:regex(~^(\d\d@):\d\d$~)|integer ' ]));
241241 }
242+
243+ public function testRegexFilterWithSpecialDelimiters ()
244+ {
245+ $ jsonType = new JsonType (['test ' => 'xyz ' ]);
246+
247+ $ this ->assertTrue ($ jsonType ->matches (['test ' => 'string:regex([xyz]) ' ]));
248+ $ this ->assertTrue ($ jsonType ->matches (['test ' => 'string:regex({xyz}) ' ]));
249+ $ this ->assertTrue ($ jsonType ->matches (['test ' => 'string:regex(<xyz>) ' ]));
250+ $ this ->assertTrue ($ jsonType ->matches (['test ' => 'string:regex((xyz)) ' ]));
251+ }
242252}
You can’t perform that action at this time.
0 commit comments