From 67fd0553ec8c342ea5b2ce6ac6c6428b5877672e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 18 Mar 2016 08:34:22 +0000 Subject: [PATCH] Bug 16095: Remove target="_blank" when a link refer to an external link If you click on a link that opens a new tab/window to another site, that tab has access to the original window through JavaScript. The browsing context is related, even if the domains are totally different. The tab retains access to the original window's object via window.opener, even if you navigate to another page or domain, in the new or original window. Access to the Window object means the new window can use Window.location to open a different URL in the original window, perfect for phishing attacks. Depending on the site's Same-Origin Policy settings, the new window may have access to other parts of the original window's DOM as well. Any 'A HREF' that contains a target of of '_blank' or '_new' or a fixed name is vulnerable. Previous security best practice often suggested creating a random fixed name for an unpredictable namespace - that won't help with this problem! Targets of '_self' and '_parent' are safe. We do not use _new (at first glance) but several _blank. Some are used to refer internal url, we do not need to update or remove them. Others are used to satisfy OPACURLOpenInNewWindow, in these case, we should add the rel="noreferrer" attribute to the a tags. In other cases, we can simply remove them and let the users discover that a mouse has more than one button (we are in 2016, they can do it!) Signed-off-by: Chris --- koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 4 +-- .../prog/en/modules/acqui/supplier.tt | 2 +- .../intranet-tmpl/prog/en/modules/basket/basket.tt | 2 +- .../prog/en/modules/catalogue/detail.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-basket.tt | 4 +-- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 32 ++++++++++---------- .../opac-tmpl/bootstrap/en/modules/opac-idref.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index f52f587..dfe9d76 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -707,12 +707,12 @@

jQuery Star Rating Plugin

-

jQuery Star Rating Plugin v3.14 by Fyneworks.com is licensed under the MIT License and the GPL License.

+

jQuery Star Rating Plugin v3.14 by Fyneworks.com is licensed under the MIT License and the GPL License.

Copyright © 2008 Fyneworks.com

jQuery insertAtCaret Plugin

-

jQuery insertAtCaret Plugin v1.0 by the phpMyAdmin devel team is licensed under the GPL License.

+

jQuery insertAtCaret Plugin v1.0 by the phpMyAdmin devel team is licensed under the GPL License.

Copyright © 2003-2010 phpMyAdmin devel team

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt index 74ff5f7..9fedd03 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt @@ -315,7 +315,7 @@ function delete_contact(ev) {

Phone: [% phone %]

Fax: [% fax %]

[% IF ( url ) %] -

Website: [% url %]

+

Website: [% url %]

[% END %] [% IF ( accountnumber ) %]

Account number: [% accountnumber %]

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt index a6e7c57..8ba7dab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -244,7 +244,7 @@ function batchDelete(){ [% FOREACH MARCNOTE IN BIBLIO_RESULT.MARCNOTES %]

[% IF MARCNOTE.marcnote.match('^https?://\S+$') %] - - [% MARCNOTE.marcnote %] + - [% MARCNOTE.marcnote %] [% ELSE %] - [% MARCNOTE.marcnote %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 40681f3..5cf6697 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -858,7 +858,7 @@ function verify_images() { [% FOREACH MARCNOTE IN MARCNOTES %]

[% IF MARCNOTE.marcnote.match('^https?://\S+$') %] - [% MARCNOTE.marcnote %] + [% MARCNOTE.marcnote %] [% ELSE %] [% MARCNOTE.marcnote FILTER html_line_break %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt index 25661ff..fa7e496 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -153,7 +153,7 @@ [% FOREACH MARCNOTE IN BIBLIO_RESULT.MARCNOTES %]

[% IF MARCNOTE.marcnote.match('^https?://\S+$') %] - - [% MARCNOTE.marcnote %] + - [% MARCNOTE.marcnote %] [% ELSE %] - [% MARCNOTE.marcnote %] [% END %] @@ -206,7 +206,7 @@ [% IF MARCurl.part %]

[% MARCurl.part %]

[% END %] [% IF OPACURLOpenInNewWindow %] - [% MARCurl.linktext %] + [% MARCurl.linktext %] [% ELSE %] [% MARCurl.linktext %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 6bdcc47..e9a52b6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -54,7 +54,7 @@ [% END %] [% IF ( OPACAmazonCoverImages ) %] [% IF ( OPACURLOpenInNewWindow ) %] - + [% ELSE %] [% END %] @@ -88,7 +88,7 @@ [% IF ( BakerTaylorEnabled && bt_id ) %] [% IF BakerTaylorBookstoreURL %] [% IF ( OPACURLOpenInNewWindow ) %] - See Baker & Taylor + See Baker & Taylor [% ELSE %] See Baker & Taylor [% END %] @@ -337,9 +337,9 @@ [% IF ( OPACURLOpenInNewWindow ) %] [% IF trackclicks == 'track' || trackclicks == 'anonymous' %] - + [% ELSE %] - + [% END %] [% ELSE %] [% IF trackclicks == 'track' || trackclicks == 'anonymous' %] @@ -436,9 +436,9 @@ Series information: [% IF ( using_https ) %] - Click to open in new window + Click to open in new window [% ELSE %] - Click to open in new window + Click to open in new window [% END %] [% END # / IF SyndeticsSeries && SyndeticsSERIES1Exists%] @@ -446,9 +446,9 @@ Audiovisual profile: [% IF ( using_https ) %] - Click to open in new window + Click to open in new window [% ELSE %] - Click to open in new window + Click to open in new window [% END %] [% END # / IF SyndeticsAVPROFILEExists %] @@ -457,9 +457,9 @@ Fiction notes: [% IF ( using_https ) %] - Click to open in new window + Click to open in new window [% ELSE %] - Click to open in new window + Click to open in new window [% END %] [% END # / IF SyndeticsFICTIONExists %] @@ -468,9 +468,9 @@ Awards: [% IF ( using_https ) %] - Click to open in new window + Click to open in new window [% ELSE %] - Click to open in new window + Click to open in new window [% END %] [% END # / IF SyndeticsAwards && SyndeticsAWARDS1Exists %] @@ -515,7 +515,7 @@ [% IF ( BakerTaylorContentURL ) %] Enhanced content: - [% IF ( OPACURLOpenInNewWindow ) %]Content Cafe[% ELSE %]Content Cafe[% END %] + [% IF ( OPACURLOpenInNewWindow ) %]Content Cafe[% ELSE %]Content Cafe[% END %] [% END # / IF BakerTaylorContentURL %] @@ -719,7 +719,7 @@ [% FOREACH MARCNOTE IN MARCNOTES %]

[% IF MARCNOTE.marcnote.match('^https?://\S+$') %] - [% MARCNOTE.marcnote %] + [% MARCNOTE.marcnote %] [% ELSE %] [% MARCNOTE.marcnote FILTER html_line_break %] [% END %] @@ -1287,13 +1287,13 @@ [% IF ITEM_RESULT.uri %] [% IF trackclicks == 'track' || trackclicks == 'anonymous' %] [% IF Koha.Preference("OPACURLOpenInNewWindow") %] - Link to resource + Link to resource [% ELSE %] Link to resource [% END %] [% ELSE %] [% IF Koha.Preference("OPACURLOpenInNewWindow") %] - [% ITEM_RESULT.uri %] + [% ITEM_RESULT.uri %] [% ELSE %] [% ITEM_RESULT.uri %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt index 85a0191..fdb1d72 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt @@ -36,7 +36,7 @@ [% doc.citation %] Koha - Sudoc + Sudoc [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js b/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js index bede2d7..49566ed 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js @@ -41,7 +41,7 @@ KOHA.Google = { gbsCallBack: function(booksInfo) { var target = ''; if (this.openInNewWindow) { - target = 'target="_blank" '; + target = 'target="_blank" rel="noreferrer" '; } for (id in booksInfo) { var book = booksInfo[id]; -- 1.7.10.4