webmail: try a bit harder not to get mailbox names or search queries in the potential stacktrace

we want to user to submit the stack trace. user can still edit before
submitting, but it won't look attractive to submit stacktraces with info that
shouldn't be there. not great that firefox is including too much info and the
effort we need to make to get it out again, but well.
This commit is contained in:
Mechiel Lukkien 2023-09-21 11:31:07 +02:00
parent d07c871f5c
commit 941a2311f0
No known key found for this signature in database
2 changed files with 26 additions and 7 deletions

View file

@ -5829,6 +5829,14 @@ window.addEventListener('load', async () => {
window.alert('Error: ' + errmsg(err));
}
});
// Keep original URL of page load, so we can remove it from stack trace if we need to.
const origLocation = {
href: window.location.href,
protocol: window.location.protocol,
host: window.location.host,
pathname: window.location.pathname,
search: window.location.search,
};
// If a JS error happens, show a box in the lower left corner, with a button to
// show details, in a popup. The popup shows the error message and a link to github
// to create an issue. We want to lower the barrier to give feedback.
@ -5839,9 +5847,10 @@ const showUnhandledError = (err, lineno, colno) => {
}
let stack = err.stack || '';
if (stack) {
// Firefox has stacks with full location.href including hash at the time of
// writing, Chromium has location.href without hash.
const loc = window.location;
log({ stack });
// At the time of writing, Firefox has stacks with full location.href of original
// page load including hash. Chromium has location.href without hash.
const loc = origLocation;
stack = '\n' + stack.replaceAll(loc.href, 'webmail.html').replaceAll(loc.protocol + '//' + loc.host + loc.pathname + loc.search, 'webmail.html');
}
else {

View file

@ -6220,6 +6220,15 @@ window.addEventListener('load', async () => {
}
})
// Keep original URL of page load, so we can remove it from stack trace if we need to.
const origLocation = {
href: window.location.href,
protocol: window.location.protocol,
host: window.location.host,
pathname: window.location.pathname,
search: window.location.search,
}
// If a JS error happens, show a box in the lower left corner, with a button to
// show details, in a popup. The popup shows the error message and a link to github
// to create an issue. We want to lower the barrier to give feedback.
@ -6230,10 +6239,11 @@ const showUnhandledError = (err: Error, lineno: number, colno: number) => {
}
let stack = err.stack || ''
if (stack) {
// Firefox has stacks with full location.href including hash at the time of
// writing, Chromium has location.href without hash.
const loc = window.location
stack = '\n'+stack.replaceAll(loc.href, 'webmail.html').replaceAll(loc.protocol+'//'+loc.host+loc.pathname+loc.search, 'webmail.html')
log({stack})
// At the time of writing, Firefox has stacks with full location.href of original
// page load including hash. Chromium has location.href without hash.
const loc = origLocation
stack = '\n'+stack.replaceAll(loc.href, 'webmail.html').replaceAll(loc.protocol + '//' + loc.host + loc.pathname + loc.search, 'webmail.html')
} else {
stack = ' (not available)'
}