summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-04-22 13:04:46 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-04-22 13:04:46 +0000
commit0e0325ee993eee2e9aac04186c46a0fde1d726a3 (patch)
treeea7a5778f60d46b4f7b5b7d795c7ebf36dbef58b /app
parent45025fecf2c0d3e060d30f860916668621dc6515 (diff)
parentc917b26f410fba6757ccf10f8b1c357ea3f2ab15 (diff)
downloadgitlab-ce-0e0325ee993eee2e9aac04186c46a0fde1d726a3.tar.gz
Merge branch 'rs-issue-2257' into 'master'
Recover from URI::Error `URI::Error` is the base class for all URI errors. Fixes #2257 and #2260 See merge request !1789
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 20457572a08..2b41d421610 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -255,11 +255,15 @@ module ApplicationHelper
#
# Returns `html_options`, adding `rel: nofollow` for external links
def add_nofollow(link, html_options = {})
- uri = URI(link)
+ begin
+ uri = URI(link)
- if uri && uri.absolute? && uri.host != Gitlab.config.gitlab.host
- rel = html_options.fetch(:rel, '')
- html_options[:rel] = (rel + ' nofollow').strip
+ if uri && uri.absolute? && uri.host != Gitlab.config.gitlab.host
+ rel = html_options.fetch(:rel, '')
+ html_options[:rel] = (rel + ' nofollow').strip
+ end
+ rescue URI::Error
+ # noop
end
html_options