Skip to content

Commit

Permalink
fix(webshell): making webshell iframe safe by making all parent acces…
Browse files Browse the repository at this point in the history
…s inside try-catch
  • Loading branch information
notthetup committed Jul 10, 2024
1 parent e6a81b3 commit 2d970ac
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/main/resources/org/arl/fjage/web/shell/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
</div>
<script>
const ignoreKeys = ['Meta-R', 'Meta-Shift-R'];
let defaultCursorWidth;
let rtime = 0;
let resizing = false;
let delta = 200;
Expand Down Expand Up @@ -160,29 +159,33 @@
}
}
window.addEventListener('load', () => {
let hideModeToggle = false;
if (window.parent.document.documentElement.classList.contains('dark')){
currentTheme = 'dark';
hideModeToggle = true;
}else if (window.parent.document.documentElement.classList.contains('light')){
currentTheme = 'light';
hideModeToggle = true;
}
hideModeToggle = hideModeToggle || window.parent.hideModeToggle;
const darkmodeBtn = document.getElementById('darkmode-tgl');
let hideModeToggle = false;
let userTheme = false;

try{
if (window.parent.document.documentElement.classList.contains('dark')){
currentTheme = 'dark';
hideModeToggle = true;
}else if (window.parent.document.documentElement.classList.contains('light')){
currentTheme = 'light';
hideModeToggle = true;
}
hideModeToggle = hideModeToggle || window.parent.hideModeToggle;
}catch(e){
// ignore
}

const term = new Terminal({
cols: 160,
rows: 50
});
fitAddon = new FitAddon.FitAddon();
term.loadAddon(fitAddon);
term.loadAddon(new WebLinksAddon.WebLinksAddon());

term.open(document.getElementById('terminal'));

fitAddon.fit();
defaultCursorWidth = term.getOption("cursorWidth");

if (currentTheme == null && window.matchMedia) currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';

Expand Down

0 comments on commit 2d970ac

Please sign in to comment.