blob: f7b12914249836aabbea84cf68724851461cdbf0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
module Gitlab
module Ci
module Pipeline
module Expression
module Lexeme
require_dependency 're2'
class Pattern < Lexeme::Value
PATTERN = %r{/(?<regexp>.+)/}.freeze
def initialize(regexp)
@value = regexp
end
def evaluate(variables = {})
@regexp = Gitlab::UntrustedRegexp.new(@value)
rescue RegexpError
raise Expression::RuntimeError, 'Invalid regular expression!'
end
def self.build(string)
new(string.match(PATTERN)[:regexp])
end
end
end
end
end
end
end
|