Fix error with about:srcdoc links; add extra check

This commit is contained in:
Adrian Vollmer 2022-10-16 18:30:09 +02:00
parent 0c4bbe69a3
commit c24f30f5ec
2 changed files with 8 additions and 1 deletions

View File

@ -91,7 +91,7 @@ var fix_link = function(a) {
a.addEventListener('click', virtual_click);
} else if (a.getAttribute('href').startsWith('#')) {
a.setAttribute('href', "about:srcdoc" + a.getAttribute('href'))
} else {
} else if (!a.getAttribute('href').startsWith('about:srcdoc')) {
// External links should open in a new tab. Browsers block links to
// sites of different origin within an iframe for security reasons.
a.setAttribute('target', "_blank");
@ -144,6 +144,7 @@ var is_virtual = function(url) {
_url.startsWith('https://') ||
_url.startsWith('http://') ||
_url.startsWith('data:') ||
_url.startsWith('about:srcdoc') ||
_url.startsWith('blob:')
));
};

View File

@ -38,6 +38,12 @@ var load_virtual_page = (function (path, get_params, anchor) {
const file = window.global_context.file_tree[path];
var iframe = createIframe();
if (!file) {
console.error("File not found:", path, get_params, anchor);
return false;
}
const data = file.data;
window.global_context.get_parameters = get_params;
if (file.mime_type == 'text/html') {