diff options
author | Robert Speicher <robert@gitlab.com> | 2016-02-27 02:35:43 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-02-27 02:35:43 +0300 |
commit | 20ac35e924d3cae1d3eb61385edad20c90a2322d (patch) | |
tree | 3b0e76d84d4b85bd298573452e929bc7f17dad2d /app | |
parent | 2c6e34bc16e7d2ddea5601998a4496cc20902fe4 (diff) | |
parent | 4d0e2979b9a17160ad93ff704e7a51f78b4f3b4c (diff) |
Merge branch 'evuez/gitlab-ce-webhook-url-spaces' into 'master'
Strip leading and trailing spaces in URL validator
_Originally opened at !2914 by @evuez._
It makes URLs in webhooks valid even if they contain leading and/or trailing spaces.
Spaces are hard to notice in input fields, this helps users by accepting leading and trailing spaces in webhooks URLs.
Fixes #13652
See merge request !2939
Diffstat (limited to 'app')
-rw-r--r-- | app/validators/url_validator.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb index 2848b9cd33d..a77beb2683d 100644 --- a/app/validators/url_validator.rb +++ b/app/validators/url_validator.rb @@ -29,8 +29,11 @@ class UrlValidator < ActiveModel::EachValidator end def valid_url?(value) + return false if value.nil? + options = default_options.merge(self.options) + value.strip! value =~ /\A#{URI.regexp(options[:protocols])}\z/ end end |