Skip to content

Commit

Permalink
Fixed way of prevening to read foreign iframe content
Browse files Browse the repository at this point in the history
  • Loading branch information
Igloczek committed Mar 19, 2017
1 parent a6711c2 commit 3026e81
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/code/Magento/PageCache/view/frontend/web/js/page-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,16 @@ define([
*/
(function lookup(element) {
// prevent cross origin iframe content reading
if (element.nodeName === "IFRAME") {
var iframeSrc = document.createElement('a');
iframeSrc.href = element.src;
if (window.location.hostname !== iframeSrc.hostname) {
if ($(element).prop('tagName') === 'IFRAME') {
var iframeHostName = $('<a>').prop('href', $(element).prop('src'))
.prop('hostname');

if (window.location.hostname !== iframeHostName) {
return [];
}
}

$(element).contents().each(function (index, el) {
var hostName, iFrameHostName;

switch (el.nodeType) {
case 1: // ELEMENT_NODE
lookup(el);
Expand Down

0 comments on commit 3026e81

Please sign in to comment.