Skip to content

Commit 5638f90

Browse files
committed
Add AllowIFrames helper
1 parent 6e7247e commit 5638f90

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

helpers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,9 @@ func (p *Policy) AllowTables() {
295295
CellVerticalAlign,
296296
).OnElements("tbody", "tfoot")
297297
}
298+
299+
func (p *Policy) AllowIFrames(vals ...SandboxValue) {
300+
p.AllowAttrs("sandbox").OnElements("iframe")
301+
302+
p.RequireSandboxOnIFrame(vals...)
303+
}

policy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ func (p *Policy) AllowURLSchemeWithCustomPolicy(
702702
return p
703703
}
704704

705+
// RequireSandboxOnIFrame will result in all iframe tags having a sandbox="" tag
706+
// Any sandbox values not specified here will be filtered from the generated HTML
705707
func (p *Policy) RequireSandboxOnIFrame(vals ...SandboxValue) {
706708
p.requireSandboxOnIFrame = make(map[string]bool)
707709

0 commit comments

Comments
 (0)