forked from ConvertGroupsAS/magento2-patches
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Patch-Magento_PageCache-M2.1.0-element-js-error-fix.patch
61 lines (58 loc) · 2.22 KB
/
Patch-Magento_PageCache-M2.1.0-element-js-error-fix.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--- view/frontend/web/js/page-cache.js 2016-12-08 21:22:42.000000000 +0300
+++ view/frontend/web/js/page-cache.js 2017-05-04 10:26:54.000000000 +0300
@@ -24,6 +24,18 @@
* @param {jQuery} element - Comment holder
*/
(function lookup(element) {
+ var iframeHostName;
+
+ // prevent cross origin iframe content reading
+ if ($(element).prop('tagName') === 'IFRAME') {
+ iframeHostName = $('<a>').prop('href', $(element).prop('src'))
+ .prop('hostname');
+
+ if (window.location.hostname !== iframeHostName) {
+ return [];
+ }
+ }
+
$(element).contents().each(function (index, el) {
switch (el.nodeType) {
case 1: // ELEMENT_NODE
@@ -35,14 +47,7 @@
break;
case 9: // DOCUMENT_NODE
- var hostName = window.location.hostname,
- iFrameHostName = $('<a>')
- .prop('href', element.prop('src'))
- .prop('hostname');
-
- if (hostName === iFrameHostName) {
- lookup($(el).find('body'));
- }
+ lookup($(el).find('body'));
break;
}
});
@@ -159,17 +164,16 @@
* @protected
*/
_replacePlaceholder: function (placeholder, html) {
+ var startReplacing = false,
+ prevSibling = null,
+ parent, contents, yy, len, element;
+
if (!placeholder || !html) {
return;
}
- var parent = $(placeholder.openElement).parent(),
- contents = parent.contents(),
- startReplacing = false,
- prevSibling = null,
- yy,
- len,
- element;
+ parent = $(placeholder.openElement).parent();
+ contents = parent.contents();
for (yy = 0, len = contents.length; yy < len; yy++) {
element = contents[yy];