Skip to content

Commit 31d443a

Browse files
committed
Change regex pattern from greedy to non-greedy
The spec mandates: > The wildcard matching MUST consume as few characters as possible.
1 parent 9656916 commit 31d443a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

deps/rabbit/src/rabbit_amqp_filter_sql.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ pattern_to_regex([EscapeChar | Rest], EscapeChar, Acc) ->
433433
end;
434434
pattern_to_regex([$% | Rest], Escape, Acc) ->
435435
%% % matches any sequence of characters (0 or more)
436-
pattern_to_regex(Rest, Escape, [$*, $. | Acc]);
436+
%% "The wildcard matching MUST consume as few characters as possible." (non-greedy)
437+
pattern_to_regex(Rest, Escape, [$?, $*, $. | Acc]);
437438
pattern_to_regex([$_ | Rest], Escape, Acc) ->
438439
%% _ matches exactly one character
439440
pattern_to_regex(Rest, Escape, [$. | Acc]);

0 commit comments

Comments
 (0)