GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit ff5284b6 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'issue_14553' into 'master'

Set target="_blank" for external links

Closes #14553

See merge request !4526
parents 97b00742 26d4e633
......@@ -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
......@@ -15,6 +15,7 @@ def call
next if link.start_with?(internal_url)
node.set_attribute('rel', 'nofollow noreferrer')
node.set_attribute('target', '_blank')
......@@ -165,17 +165,27 @@ def doc(html = @html)
describe 'ExternalLinkFilter' do
it 'adds nofollow to external link' do
link = doc.at_css('a:contains("Google")')
expect(link.attr('rel')).to include('nofollow')
it 'adds noreferrer to external link' do
link = doc.at_css('a:contains("Google")')
expect(link.attr('rel')).to include('noreferrer')
it 'adds _blank to target attribute for external links' do
link = doc.at_css('a:contains("Google")')
expect(link.attr('target')).to match('_blank')
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'
......@@ -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](
- [GitLab Root](<%= Gitlab.config.gitlab.url %>)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment