diff options
author | Stan Hu <stanhu@gmail.com> | 2018-12-09 10:23:39 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-12-09 18:59:54 +0300 |
commit | 401be1d17fb839f68358581c0c74560bd4a24f8f (patch) | |
tree | 9d6df7b3beffee066709ed820214d019997f3560 | |
parent | 7cb0dd98590e8fdd7483b9f61643a0daa23c2b67 (diff) |
Only allow strings in URL::Sanitizer.valid?
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55079
-rw-r--r-- | changelogs/unreleased/sh-ignore-arrays-url-sanitizer.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/url_sanitizer.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/url_sanitizer_spec.rb | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/changelogs/unreleased/sh-ignore-arrays-url-sanitizer.yml b/changelogs/unreleased/sh-ignore-arrays-url-sanitizer.yml new file mode 100644 index 00000000000..c010bd1f540 --- /dev/null +++ b/changelogs/unreleased/sh-ignore-arrays-url-sanitizer.yml @@ -0,0 +1,5 @@ +--- +title: Only allow strings in URL::Sanitizer.valid? +merge_request: 23675 +author: +type: fixed diff --git a/lib/gitlab/url_sanitizer.rb b/lib/gitlab/url_sanitizer.rb index 035268bc4f2..880712de5fe 100644 --- a/lib/gitlab/url_sanitizer.rb +++ b/lib/gitlab/url_sanitizer.rb @@ -14,6 +14,7 @@ module Gitlab def self.valid?(url) return false unless url.present? + return false unless url.is_a?(String) uri = Addressable::URI.parse(url.strip) diff --git a/spec/lib/gitlab/url_sanitizer_spec.rb b/spec/lib/gitlab/url_sanitizer_spec.rb index b41a81a8167..6e98a999766 100644 --- a/spec/lib/gitlab/url_sanitizer_spec.rb +++ b/spec/lib/gitlab/url_sanitizer_spec.rb @@ -41,6 +41,7 @@ describe Gitlab::UrlSanitizer do false | '123://invalid:url' false | 'valid@project:url.git' false | 'valid:pass@project:url.git' + false | %w(test array) true | 'ssh://example.com' true | 'ssh://:@example.com' true | 'ssh://foo@example.com' |