BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ff5284b6
Commit
ff5284b6
authored
Jun 08, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_14553' into 'master'
Set target="_blank" for external links Closes #14553 See merge request !4526
parents
97b00742
26d4e633
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
1 deletion
+13
-1
CHANGELOG
CHANGELOG
+1
-0
external_link_filter.rb
lib/banzai/filter/external_link_filter.rb
+1
-0
markdown_spec.rb
spec/features/markdown_spec.rb
+10
-0
markdown.md.erb
spec/fixtures/markdown.md.erb
+1
-1
No files found.
CHANGELOG
View file @
ff5284b6
...
...
@@ -50,6 +50,7 @@ v 8.9.0 (unreleased)
- An indicator is now displayed at the top of the comment field for confidential issues.
- RepositoryCheck::SingleRepositoryWorker public and private methods are now instrumented
- Improve issuables APIs performance when accessing notes !4471
- External links now open in a new tab
v 8.8.4 (unreleased)
- Ensure branch cleanup regardless of whether the GitHub import process succeeds
...
...
lib/banzai/filter/external_link_filter.rb
View file @
ff5284b6
...
...
@@ -15,6 +15,7 @@ module Banzai
next
if
link
.
start_with?
(
internal_url
)
node
.
set_attribute
(
'rel'
,
'nofollow noreferrer'
)
node
.
set_attribute
(
'target'
,
'_blank'
)
end
doc
...
...
spec/features/markdown_spec.rb
View file @
ff5284b6
...
...
@@ -165,17 +165,27 @@ describe 'GitLab Markdown', feature: true do
describe
'ExternalLinkFilter'
do
it
'adds nofollow to external link'
do
link
=
doc
.
at_css
(
'a:contains("Google")'
)
expect
(
link
.
attr
(
'rel'
)).
to
include
(
'nofollow'
)
end
it
'adds noreferrer to external link'
do
link
=
doc
.
at_css
(
'a:contains("Google")'
)
expect
(
link
.
attr
(
'rel'
)).
to
include
(
'noreferrer'
)
end
it
'adds _blank to target attribute for external links'
do
link
=
doc
.
at_css
(
'a:contains("Google")'
)
expect
(
link
.
attr
(
'target'
)).
to
match
(
'_blank'
)
end
it
'ignores internal link'
do
link
=
doc
.
at_css
(
'a:contains("GitLab Root")'
)
expect
(
link
.
attr
(
'rel'
)).
not_to
match
'nofollow'
expect
(
link
.
attr
(
'target'
)).
not_to
match
'_blank'
end
end
end
...
...
spec/fixtures/markdown.md.erb
View file @
ff5284b6
...
...
@@ -136,7 +136,7 @@ But it shouldn't autolink text inside certain tags:
### ExternalLinkFilter
External links get a `rel="nofollow
"` attribute
:
External links get a `rel="nofollow
noreferrer"` and `target="_blank"` attributes
:
- [Google](https://google.com/)
- [GitLab Root](
<%=
Gitlab
.
config
.
gitlab
.
url
%>
)
...
...
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