Only allow strings in URL::Sanitizer.valid?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55079
This commit is contained in:
Stan Hu 2018-12-08 23:23:39 -08:00
parent 7cb0dd9859
commit 401be1d17f
3 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
title: Only allow strings in URL::Sanitizer.valid?
merge_request: 23675
author:
type: fixed

View File

@ -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)

View File

@ -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'