mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-21 21:11:35 +01:00
[PM-1407] Improve iframe sandbox detection (#5976)
* improve iframe sandbox detection * code cleanup Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com> * update autofill v1 logic as well --------- Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com>
This commit is contained in:
parent
fd119f08ec
commit
42193aecb8
@ -768,8 +768,16 @@
|
|||||||
|
|
||||||
// Detect if within an iframe, and the iframe is sandboxed
|
// Detect if within an iframe, and the iframe is sandboxed
|
||||||
function isSandboxed() {
|
function isSandboxed() {
|
||||||
// self.origin is 'null' if inside a frame with sandboxed csp or iframe tag
|
// self.origin is 'null' if inside a frame with sandboxed csp or iframe tag
|
||||||
return self.origin == null || self.origin === 'null';
|
if (String(self.origin).toLowerCase() === "null") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.frameElement?.hasAttribute("sandbox")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return location.hostname === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function doFill(fillScript) {
|
function doFill(fillScript) {
|
||||||
|
@ -849,7 +849,15 @@ function fill(document: Document, fillScript: AutofillScript) {
|
|||||||
// Detect if within an iframe, and the iframe is sandboxed
|
// Detect if within an iframe, and the iframe is sandboxed
|
||||||
function isSandboxed() {
|
function isSandboxed() {
|
||||||
// self.origin is 'null' if inside a frame with sandboxed csp or iframe tag
|
// self.origin is 'null' if inside a frame with sandboxed csp or iframe tag
|
||||||
return self.origin == null || self.origin === "null";
|
if (String(self.origin).toLowerCase() === "null") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.frameElement?.hasAttribute("sandbox")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return location.hostname === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function doFill(fillScript: AutofillScript) {
|
function doFill(fillScript: AutofillScript) {
|
||||||
|
Loading…
Reference in New Issue
Block a user