diff options
author | Robert Speicher <robert@gitlab.com> | 2016-07-06 15:06:01 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-07-06 15:06:01 +0000 |
commit | be018ba8c4f61babfea494a3946df9931d476a8a (patch) | |
tree | cf5acc63374a7a570ae03deaf1800b183806be07 /lib | |
parent | 400f9f72233c6c5390367a95bf11ebee09c86d2c (diff) | |
parent | 54a50bf81d7bb304adaedffd8eb3e0bc0fc348a9 (diff) | |
download | gitlab-ce-be018ba8c4f61babfea494a3946df9931d476a8a.tar.gz |
Merge branch 'fix/import-url-validator' into 'master'
Fixing URL validation for import_url on projects
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/17536
This MR fixes problems related to bypassing `import_url` validation on projects. This makes sure the URL is properly validated so we don't enter crap and fail while running workers that handle this URL.
It also adds a migration to fix current invalid `import_url`s
See merge request !4753
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/url_sanitizer.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/url_sanitizer.rb b/lib/gitlab/url_sanitizer.rb index 7d02fe3c971..86ed18fb50d 100644 --- a/lib/gitlab/url_sanitizer.rb +++ b/lib/gitlab/url_sanitizer.rb @@ -6,8 +6,16 @@ module Gitlab content.gsub(regexp) { |url| new(url).masked_url } end + def self.valid?(url) + Addressable::URI.parse(url.strip) + + true + rescue Addressable::URI::InvalidURIError + false + end + def initialize(url, credentials: nil) - @url = Addressable::URI.parse(url) + @url = Addressable::URI.parse(url.strip) @credentials = credentials end |