diff options
| author | Robert Speicher <rspeicher@gmail.com> | 2015-04-21 14:36:06 -0400 |
|---|---|---|
| committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-21 22:02:44 -0400 |
| commit | c917b26f410fba6757ccf10f8b1c357ea3f2ab15 (patch) | |
| tree | 8d82f4bea6df1d8f8134aec37ca2e7d9f8206665 /app/helpers/application_helper.rb | |
| parent | d7f61affaf845f44b4cc995e34eb1606c47c8eff (diff) | |
| download | gitlab-ce-c917b26f410fba6757ccf10f8b1c357ea3f2ab15.tar.gz | |
Recover from all `URI::Error`s
Fixes #2257
Fixes #2260
Diffstat (limited to 'app/helpers/application_helper.rb')
| -rw-r--r-- | app/helpers/application_helper.rb | 12 |
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 |
