Skip to content
Snippets Groups Projects

Fix CI rules-if comparison with Regexp variables

Merged Furkan Ayhan requested to merge 35438-ci-variable-comparison-with-regexp into master
5 files
+ 67
11
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -12,14 +12,14 @@ def evaluate(variables = {})
text = @left.evaluate(variables)
regexp = @right.evaluate(variables)
return false unless regexp
if ::Feature.enabled?(:ci_fix_rules_if_comparison_with_regexp_variable, default_enabled: :yaml)
# All variables are evaluated as strings, even if they are regexp strings.
# So, we need to convert them to regexp objects.
regexp = Gitlab::UntrustedRegexp::RubySyntax.fabricate(regexp) || regexp
regexp = Lexeme::Pattern.build_safe(regexp)&.evaluate(variables) || regexp
end
return false unless regexp
regexp.scan(text.to_s).present?
end
Loading