Skip to content

Commit

Permalink
escape Matches' value at runtime
Browse files Browse the repository at this point in the history
Since the string is static, we can escape at initialization time
But Matches may end up with MatchesPath or something.
So Just escaping at runtime
  • Loading branch information
kbrock committed May 23, 2024
1 parent f851093 commit e1bce92
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/floe/workflow/choice_rule/matches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ module Floe
class Workflow
class ChoiceRule
class Matches < Floe::Workflow::ChoiceRule
def initialize(payload, *, **)
super
# NOTE: only StringMatches exists (so no Path option)
# Since this is static, we're converting it up front
@ref = Regexp.escape(@ref).gsub('\*', '.*?')
end

def true?(context, input)
lhs = variable_value(context, input)
valid?(lhs) && lhs.match?(ref)
rhs = compare_value(context, input)
valid?(lhs) && lhs.match?(Regexp.escape(rhs).gsub('\*', '.*?'))
end
end
end
Expand Down

0 comments on commit e1bce92

Please sign in to comment.