Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c917b26f
Commit
c917b26f
authored
Apr 21, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recover from all `URI::Error`s
Fixes #2257 Fixes #2260
parent
d7f61aff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+8
-4
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+10
-0
No files found.
app/helpers/application_helper.rb
View file @
c917b26f
...
@@ -255,11 +255,15 @@ module ApplicationHelper
...
@@ -255,11 +255,15 @@ module ApplicationHelper
#
#
# Returns `html_options`, adding `rel: nofollow` for external links
# Returns `html_options`, adding `rel: nofollow` for external links
def
add_nofollow
(
link
,
html_options
=
{})
def
add_nofollow
(
link
,
html_options
=
{})
uri
=
URI
(
link
)
begin
uri
=
URI
(
link
)
if
uri
&&
uri
.
absolute?
&&
uri
.
host
!=
Gitlab
.
config
.
gitlab
.
host
if
uri
&&
uri
.
absolute?
&&
uri
.
host
!=
Gitlab
.
config
.
gitlab
.
host
rel
=
html_options
.
fetch
(
:rel
,
''
)
rel
=
html_options
.
fetch
(
:rel
,
''
)
html_options
[
:rel
]
=
(
rel
+
' nofollow'
).
strip
html_options
[
:rel
]
=
(
rel
+
' nofollow'
).
strip
end
rescue
URI
::
Error
# noop
end
end
html_options
html_options
...
...
spec/helpers/application_helper_spec.rb
View file @
c917b26f
...
@@ -249,6 +249,16 @@ describe ApplicationHelper do
...
@@ -249,6 +249,16 @@ describe ApplicationHelper do
expect
(
link_to
(
'Example'
,
'http://example.foo/bar'
)).
expect
(
link_to
(
'Example'
,
'http://example.foo/bar'
)).
to
eq
'<a href="http://example.foo/bar">Example</a>'
to
eq
'<a href="http://example.foo/bar">Example</a>'
end
end
it
'should not raise an error when given a bad URI'
do
expect
{
link_to
(
'default'
,
'if real=1 RANDOM; if real>1 IDLHS; if real>500 LHS'
)
}.
not_to
raise_error
end
it
'should not raise an error when given a bad mailto URL'
do
expect
{
link_to
(
'email'
,
'mailto://foo.bar@example.es?subject=Subject%20Line'
)
}.
not_to
raise_error
end
end
end
describe
'markup_render'
do
describe
'markup_render'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment