Skip to content
This repository has been archived by the owner on Nov 27, 2021. It is now read-only.

Commit

Permalink
Issue #160 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwouaiebe committed Apr 21, 2021
1 parent 0307cbe commit 220d0bd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buildNumber.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "buildNumber" : "00059"}
{ "buildNumber" : "00073"}
6 changes: 4 additions & 2 deletions src/printMap/PrintFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { theConfig } from '../data/Config.js';
import { theTranslator } from '../UI/Translator.js';
import { theLayersToolbarUI } from '../UI/LayersToolbarUI.js';
import { theAPIKeysManager } from '../core/APIKeysManager.js';
import { theHTMLSanitizer } from '../util/HTMLSanitizer.js';
import { ZERO, TWO, LAT, LNG } from '../util/Constants.js';

const OUR_TILE_SIZE = 256;
Expand Down Expand Up @@ -514,12 +515,13 @@ function ourNewPrintFactory ( ) {
leafletLayer = window.L.tileLayer.wms ( url, layer.wmsOptions );
}

leafletLayer.options.attribution =
leafletLayer.options.attribution = theHTMLSanitizer.sanitizeToHtmlString (
' © <a href="https://www.openstreetmap.org/copyright" target="_blank" ' +
'title="OpenStreetMap contributors">OpenStreetMap contributors</a> ' +
layer.attribution +
'| © <a href="https://github.com/wwwouaiebe" target="_blank" ' +
'title="https://github.com/wwwouaiebe">Travel & Notes</a> ';
'title="https://github.com/wwwouaiebe">Travel & Notes</a> '
).htmlString;

return leafletLayer;
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/HTMLElementsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ function ourAddProperties ( element, properties ) {
}
}
}
if ( element.target ) {
element.rel = 'noopener noreferrer';
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/util/HTMLSanitizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ function ourSanitizeToHtmlElement ( htmlString, targetNode ) {
}
);
}
if ( currentNode.hasAttribute ( 'target' ) ) {
newChildNode.setAttribute ( 'rel', 'noopener noreferrer' );
}
newNode.appendChild ( newChildNode );
cloneNode ( currentNode, newChildNode );
}
Expand Down Expand Up @@ -400,6 +403,9 @@ function ourSanitizeToHtmlString ( htmlString ) {
);
let isSvg = ( 'svg' === nodeName || 'text' === nodeName || 'polyline' === nodeName );
targetString += '<' + nodeName;
if ( currentNode.hasAttribute ( 'target' ) ) {
targetString += ' rel="noopener noreferrer"';
}
validAttributesNames.forEach (
validAttributeName => {
if ( isSvg ) {
Expand Down

0 comments on commit 220d0bd

Please sign in to comment.