Skip to content

Commit a361fa7

Browse files
committed
Add rel='noopener' to all links opening in a new window
Browsers younger than ~5 years don't need this, but older browsers might cause problems. Code style change as demanded by eslint Remove accidentally added `id` attribute Fix test as it was intended
1 parent a3071d5 commit a361fa7

File tree

15 files changed

+28
-18
lines changed

15 files changed

+28
-18
lines changed

plugins/help/help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function error_page($args)
162162
&& $rcmail->request_status == rcube::REQUEST_ERROR_URL
163163
&& ($url = $rcmail->config->get('help_csrf_info'))
164164
) {
165-
$args['text'] .= '<p>' . html::a(['href' => $url, 'target' => '_blank'], $this->gettext('csrfinfo')) . '</p>';
165+
$args['text'] .= '<p>' . html::a(['href' => $url, 'target' => '_blank', 'rel' => 'noopener'], $this->gettext('csrfinfo')) . '</p>';
166166
}
167167

168168
return $args;

program/actions/contacts/show.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public static function render_url_value($url)
194194
return html::a([
195195
'href' => $prefix . $url,
196196
'target' => '_blank',
197+
'rel' => 'noopener',
197198
'class' => 'url',
198199
],
199200
rcube::Q($url)

program/actions/mail/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ public static function washtml_link_callback($tag, $attribs, $content, $washtml)
13241324
}
13251325
} elseif (!empty($attrib['href']) && $attrib['href'][0] != '#') {
13261326
$attrib['target'] = '_blank';
1327+
$attrib['rel'] = 'noopener';
13271328
}
13281329

13291330
// Better security by adding rel="noreferrer" (#1484686)

program/actions/settings/about.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public function run($args = [])
4343
},
4444
'license' => static function () {
4545
return 'This program is free software; you can redistribute it and/or modify it under the terms '
46-
. 'of the <a href="https://www.gnu.org/licenses/gpl.html" target="_blank">GNU General Public License</a> '
46+
. 'of the <a href="https://www.gnu.org/licenses/gpl.html" target="_blank" rel="noopener">GNU General Public License</a> '
4747
. 'as published by the Free Software Foundation, either version 3 of the License, '
4848
. 'or (at your option) any later version.<br/>'
49-
. 'Some <a href="https://roundcube.net/license" target="_blank">exceptions</a> '
49+
. 'Some <a href="https://roundcube.net/license" target="_blank" rel="noopener">exceptions</a> '
5050
. 'for skins &amp; plugins apply.';
5151
},
5252
]);
@@ -117,6 +117,7 @@ public static function plugins_list($attrib)
117117
if ($uri) {
118118
$uri = html::a([
119119
'target' => '_blank',
120+
'rel' => 'noopener',
120121
'href' => rcube::Q($uri),
121122
],
122123
rcube::Q($rcmail->gettext('download'))
@@ -128,6 +129,7 @@ public static function plugins_list($attrib)
128129
if (!empty($data['license_uri'])) {
129130
$license = html::a([
130131
'target' => '_blank',
132+
'rel' => 'noopener',
131133
'href' => rcube::Q($data['license_uri']),
132134
],
133135
rcube::Q($data['license'])
@@ -155,7 +157,7 @@ public static function skin_info($attrib)
155157
html::span('skinitem', html::span('skinname', rcube::Q($meta['name'])) . (!empty($meta['version']) ? '&nbsp;(' . $meta['version'] . ')' : '') . html::br()
156158
. (!empty($meta['author_link']) ? html::span('skinauthor', $rcmail->gettext(['name' => 'skinauthor', 'vars' => ['author' => $meta['author_link']]])) . html::br() : '')
157159
. (!empty($meta['license_link']) ? html::span('skinlicense', $rcmail->gettext('license') . ':&nbsp;' . $meta['license_link']) . html::br() : '')
158-
. (!empty($meta['uri']) ? html::span('skinhomepage', $rcmail->gettext('source') . ':&nbsp;' . html::a(['href' => $meta['uri'], 'target' => '_blank', 'tabindex' => '-1'], rcube::Q($rcmail->gettext('download')))) : ''))
160+
. (!empty($meta['uri']) ? html::span('skinhomepage', $rcmail->gettext('source') . ':&nbsp;' . html::a(['href' => $meta['uri'], 'target' => '_blank', 'rel' => 'noopener', 'tabindex' => '-1'], rcube::Q($rcmail->gettext('download')))) : ''))
159161
);
160162

161163
return $content;

program/actions/settings/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ public static function user_prefs($current = null)
15131513
'content' => html::div(
15141514
['style' => 'display:none', 'class' => 'boxwarning', 'id' => 'mailvelope-warning'],
15151515
str_replace(
1516-
'Mailvelope', '<a href="https://www.mailvelope.com" target="_blank">Mailvelope</a>',
1516+
'Mailvelope', '<a href="https://www.mailvelope.com" target="_blank" rel="noopener">Mailvelope</a>',
15171517
rcube::Q($rcmail->gettext('mailvelopenotfound'))
15181518
)
15191519
. html::script([], "if (!parent.mailvelope) \$('#mailvelope-warning').show()")

program/include/rcmail_install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ private function _showhint($message, $url = '')
811811
$hint = rcube::Q($message);
812812

813813
if ($url) {
814-
$hint .= ($hint ? '; ' : '') . 'See <a href="' . rcube::Q($url) . '" target="_blank">' . rcube::Q($url) . '</a>';
814+
$hint .= ($hint ? '; ' : '') . 'See <a href="' . rcube::Q($url) . '" target="_blank" rel="noopener">' . rcube::Q($url) . '</a>';
815815
}
816816

817817
if ($hint) {

program/include/rcmail_output.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public function get_skin_info($name = null)
7373
$meta = INSTALL_PATH . "skins/{$skin}/meta.json";
7474
if (is_readable($meta) && ($json = json_decode(file_get_contents($meta), true))) {
7575
$data = $json;
76-
$data['author_link'] = !empty($json['url']) ? html::a(['href' => $json['url'], 'target' => '_blank'], rcube::Q($json['author'])) : rcube::Q($json['author']);
77-
$data['license_link'] = !empty($json['license-url']) ? html::a(['href' => $json['license-url'], 'target' => '_blank', 'tabindex' => '-1'], rcube::Q($json['license'])) : rcube::Q($json['license']);
76+
$data['author_link'] = !empty($json['url']) ? html::a(['href' => $json['url'], 'target' => '_blank', 'rel' => 'noopener'], rcube::Q($json['author'])) : rcube::Q($json['author']);
77+
$data['license_link'] = !empty($json['license-url']) ? html::a(['href' => $json['license-url'], 'target' => '_blank', 'rel' => 'noopener', 'tabindex' => '-1'], rcube::Q($json['license'])) : rcube::Q($json['license']);
7878
}
7979

8080
$composer = INSTALL_PATH . "/skins/{$skin}/composer.json";

program/js/app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4425,7 +4425,13 @@ function rcube_webmail() {
44254425

44264426
li.append($('<label>').addClass('keyid').text(ref.get_label('keyid')));
44274427
li.append($('<a>').text(keyrec.keyid.substr(-8).toUpperCase())
4428-
.attr({ href: keyrec.info, target: '_blank', tabindex: '-1' }));
4428+
.attr({
4429+
href: keyrec.info,
4430+
target: '_blank',
4431+
rel: 'noopener',
4432+
tabindex: '-1',
4433+
})
4434+
);
44294435

44304436
li.append($('<label>').addClass('keylen').text(ref.get_label('keylength')));
44314437
li.append($('<span>').text(keyrec.keylen));

program/js/editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function rcube_text_editor(config, id) {
195195
ed.on('click', function (e) {
196196
var link = $(e.target).closest('a');
197197
if (link.length && e.shiftKey) {
198-
window.open(link.get(0).href, '_blank');
198+
window.open(link.get(0).href, '_blank', 'noopener=true');
199199
return false;
200200
}
201201
});

program/lib/Roundcube/rcube_text2html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function convert()
139139
protected function converter($text)
140140
{
141141
// make links and email-addresses clickable
142-
$attribs = ['link_attribs' => ['rel' => 'noreferrer', 'target' => '_blank']];
142+
$attribs = ['link_attribs' => ['rel' => 'noreferrer noopener', 'target' => '_blank']];
143143
$replacer = new $this->config['replacer']($attribs);
144144

145145
if ($this->config['flowed']) {

0 commit comments

Comments
 (0)