Merge pull request #4188 from GHolk/master

Fix #4158: bookmarklet execution bug
This commit is contained in:
Oliver Blanthorn 2022-04-25 11:39:31 +02:00 committed by GitHub
commit bcad918899
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1326,14 +1326,8 @@ export async function open(...urlarr: string[]) {
// Open URLs that firefox won't let us by running `firefox <URL>` on the command line // Open URLs that firefox won't let us by running `firefox <URL>` on the command line
return nativeopen(url) return nativeopen(url)
} else if (/^javascript:/.exec(url)) { } else if (/^javascript:/.exec(url)) {
const bookmarklet = url.replace(/^javascript:/, "") const escapeUrl = url.replace(/[\\"]/g, "\\$&")
document.body.append( window.eval(`window.location.href = "${escapeUrl}"`)
html`
<script>
${bookmarklet}
</script>
`,
)
} else { } else {
const tab = await ownTab() const tab = await ownTab()
return openInTab(tab, {}, urlarr) return openInTab(tab, {}, urlarr)