Skip to content
Snippets Groups Projects
Commit 79501c65 authored by Bojan Marjanovic's avatar Bojan Marjanovic :five:
Browse files

Fixes JiraIssueKey extractor regex format bug

Adds a condition to check between different regex types

Changelog: fixed
parent d132f218
No related branches found
No related tags found
1 merge request!121833Resolve 500 error for Jira issue regex
......@@ -12,7 +12,9 @@ def initialize(*text, custom_regex: nil)
end
def issue_keys
@text.scan(@match_regex).flatten.uniq
return @text.scan(@match_regex).flatten.uniq if @match_regex.is_a?(Regexp)
@match_regex.scan(@text).flatten.uniq
end
end
end
......@@ -41,5 +41,13 @@
is_expected.to contain_exactly('TEST-01')
end
end
context 'with untrusted regex' do
subject { described_class.new('TEST-01 some A-100', custom_regex: Gitlab::UntrustedRegexp.new("[A-Z]{2,}-\\d+")).issue_keys }
it 'returns all valid Jira issue keys' do
is_expected.to contain_exactly('TEST-01')
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment