Skip to content

Commit

Permalink
Set path for cookies and change window access from iframe,
Browse files Browse the repository at this point in the history
so access from tutorials don't become a cross-origin access

Change-Id: I49b9c401b3de20cb2ba7fb8c6fc5649d6b105891
  • Loading branch information
Akron committed Jan 16, 2025
1 parent aa3dcfe commit 9bbd770
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Keep plugin state in statemanager (fixes #201; diewald)
- Fix alerts in hint helper (diewald)
- Don't send empty pipes and states via query param (diewald)
- Fix access of iframe location in tutorials. (diewald)

0.58 2024-11-15
- Cookie path is settable now (hebasta)
Expand Down
7 changes: 5 additions & 2 deletions dev/js/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ define([

// Set base URL
KorAP.URL = d.body.getAttribute('data-korap-url') || "";




// Create suffix if KorAP is run in a subfolder
KorAP.session = sessionClass.create(
KorAP.URL.length > 0 ? 'kalamarJS-' + KorAP.URL.slugify() : 'kalamarJS'
(KorAP.URL.length > 0 ? 'kalamarJS-' + KorAP.URL.slugify() : 'kalamarJS'),
KorAP.URL
);

// Get koralQuery response
Expand Down
23 changes: 11 additions & 12 deletions dev/js/src/tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,22 @@ define(['session','buttongroup','util'], function (sessionClass, buttonGroupClas
let page = obj;

if (typeof page != 'string') {
const l = this._iframe !== null ? window.frames[0].location : window.location;
const l = this._iframe !== null ? this._iframe.contentWindow.location : window.location;

page = l.pathname + l.search;
page = l.pathname + l.search;

for (let i = 1; i < 5; i++) {
if ((obj.nodeName === 'SECTION' || obj.nodeName === 'PRE') && obj.hasAttribute('id')) {
page += '#' + obj.getAttribute('id');
break;
}
else {
obj = obj.parentNode;
for (let i = 1; i < 5; i++) {
if ((obj.nodeName === 'SECTION' || obj.nodeName === 'PRE') && obj.hasAttribute('id')) {
page += '#' + obj.getAttribute('id');
break;
}
else {
obj = obj.parentNode;
if (obj === null)
break;
};
};
};
};
};

this._session.set('tutpage', page);
},

Expand Down

0 comments on commit 9bbd770

Please sign in to comment.