Skip to content

Commit 924c7c4

Browse files
authored
Merge pull request #99 from AI-Tournaments/patch
Update external sources protection.
2 parents 1dd2d05 + eff41d6 commit 924c7c4

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

Dev/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function a(){
8686
if(url && (url[0] === '?' || url[0] === '!')){
8787
if(acceptedDev === undefined){
8888
const session = GitHubApi.getSessionStorage();
89-
acceptedDev = 'I accept unsandboxed sources' === (prompt('By having exclamation (!) and question (?) marks first in the URL you side steps all security features and you do so at your own risk. Only do this to URLs for code that you trust.\n\nWrite "I accept unsandboxed sources" to allow unsandboxed sources.')??'').toLowerCase();
89+
const passphrase = 'I accept unsandboxed sources';
90+
acceptedDev = (prompt('By having exclamation (!) and question (?) marks first in the URL you side steps all security features and you do so at your own risk. Only do this to URLs for code that you trust.\n\nWrite "'+passphrase+'" to allow unsandboxed sources.')??'').toLowerCase() === passphrase.toLowerCase();
9091
session.acceptedDev = acceptedDev;
9192
GitHubApi.setSessionStorage(session);
9293
}

Replay/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,12 @@ function a(){
436436
}
437437
let url = option.value;
438438
const session = GitHubApi.getSessionStorage();
439-
if(!url.startsWith('https://ai-tournaments.github.io/') && !session?.externalReplaysAccepted){
440-
session.externalReplaysAccepted = 'I accept external replay viewers' === (prompt('External replays are by default blocked for security reasons. do so at your own risk. Only do this to URLs for code that you trust.\n\nWrite "I accept external replays" to allow external replay viewers.')??'').toLowerCase();
439+
if(!url.startsWith('https://ai-tournaments.github.io/') && url.startsWith('http') && !session?.externalReplaysAccepted){
440+
const passphrase = 'I accept external replay viewers';
441+
session.externalReplaysAccepted = (prompt('External replays are by default blocked for security reasons, since they are outside of AI-Tournaments control. So use them at your own risk. Only do this to URLs for code that you trust.\n\nWrite "'+passphrase+'" to allow external replay viewers.')??'').toLowerCase() === passphrase.toLowerCase();
441442
GitHubApi.setSessionStorage(session);
442443
}
443-
if(url.startsWith('https://ai-tournaments.github.io/') || session?.externalReplaysAccepted){
444+
if(url.startsWith('https://ai-tournaments.github.io/') || session.externalReplaysAccepted){
444445
_element_iframe.dataset.arenaResult = JSON.stringify(_replayData.body);
445446
_element_iframe.src = url;
446447
document.getElementById('open-replay-in-new-tab').addEventListener('click', ()=>{

0 commit comments

Comments
 (0)