Skip to content

Commit a3d3411

Browse files
authored
custom-html widget iframe allow fix (#1698)
1 parent 46885da commit a3d3411

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<iframe data-bind="attr: { srcdoc: htmlCode }, styled: styles"
2-
sandbox="allow-scripts allow-modals allow-forms"
1+
<iframe data-bind="attr: { srcdoc: htmlCode, sandbox: iframeSandboxAllows }, styled: styles"
32
frameborder="0"
43
></iframe>

src/components/custom-html/ko/customHtmlViewModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import template from "./customHtmlView.html";
33
import { widgetSelector } from "../constants";
44
import { Component } from "@paperbits/common/ko/decorators";
55
import { StyleModel } from "@paperbits/common/styles";
6+
import { iframeSandboxAllows } from "../../../constants";
67

78
@Component({
89
selector: widgetSelector,
@@ -11,6 +12,7 @@ import { StyleModel } from "@paperbits/common/styles";
1112
export class CustomHtmlViewModel {
1213
public readonly styles: ko.Observable<StyleModel>;
1314
public readonly htmlCode: ko.Observable<string>;
15+
public readonly iframeSandboxAllows: string = iframeSandboxAllows;
1416

1517
constructor() {
1618
this.htmlCode = ko.observable();

src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,8 @@ export const genericHttpRequestError = "Server error. Unable to send request. Pl
267267

268268
export const oauthSessionKey = "oauthSession";
269269
export const reservedCharTuplesForOData: [string, string][] = [["'", "''"]];
270+
271+
/**
272+
* List of allowed attributes for a sandboxed iframe.
273+
*/
274+
export const iframeSandboxAllows = "allow-scripts allow-modals allow-forms allow-downloads allow-popups-to-escape-sandbox allow-top-navigation allow-presentation allow-orientation-lock allow-pointer-lock";

0 commit comments

Comments
 (0)