Commit 31b02fc2 authored by Douwe Maan's avatar Douwe Maan

Don't allow spaces in dependency linker value regex

parent e20eb712
module Gitlab
module DependencyLinker
class BaseLinker
URL_REGEX = %r{https?://[^'"]+}.freeze
REPO_REGEX = %r{[^/'"]+/[^/'"]+}.freeze
URL_REGEX = %r{https?://[^'" ]+}.freeze
REPO_REGEX = %r{[^/'" ]+/[^/'" ]+}.freeze
class_attribute :file_type
......@@ -69,7 +69,7 @@ module Gitlab
@highlighted_lines ||= highlighted_text.lines
end
def regexp_for_value(value, default: /[^'"]+/)
def regexp_for_value(value, default: /[^'" ]+/)
case value
when Array
Regexp.union(value.map { |v| regexp_for_value(v, default: default) })
......
......@@ -24,8 +24,8 @@ module Gitlab
# link_json('specific_package', '1.0.1', link: :key)
# # Will link `specific_package` in `"specific_package": "1.0.1"`
def link_json(key, value = nil, link: :value, &url_proc)
key = regexp_for_value(key, default: /[^"]+/)
value = regexp_for_value(value, default: /[^"]+/)
key = regexp_for_value(key, default: /[^" ]+/)
value = regexp_for_value(value, default: /[^" ]+/)
if link == :value
value = /(?<name>#{value})/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment