diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-25 23:52:39 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-25 23:52:39 +0300 |
commit | 31b02fc210ffcde72a9d7882ab07979ed18a023b (patch) | |
tree | 96a90841d3252ffaaf4bdcb51ac8d4ec9e8cdab0 /lib | |
parent | e20eb71203aa29458d7f51a27d42a3d8208e2494 (diff) |
Don't allow spaces in dependency linker value regex
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/dependency_linker/base_linker.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/dependency_linker/json_linker.rb | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/gitlab/dependency_linker/base_linker.rb b/lib/gitlab/dependency_linker/base_linker.rb index 7ba0b3c39b7..7bbd154eb03 100644 --- a/lib/gitlab/dependency_linker/base_linker.rb +++ b/lib/gitlab/dependency_linker/base_linker.rb @@ -1,8 +1,8 @@ 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) }) diff --git a/lib/gitlab/dependency_linker/json_linker.rb b/lib/gitlab/dependency_linker/json_linker.rb index 1b1ca000977..a8ef25233d8 100644 --- a/lib/gitlab/dependency_linker/json_linker.rb +++ b/lib/gitlab/dependency_linker/json_linker.rb @@ -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})/ |