Skip to content

Commit

Permalink
Add AllowIFrames helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiz committed Dec 30, 2021
1 parent 6e7247e commit 5638f90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,9 @@ func (p *Policy) AllowTables() {
CellVerticalAlign,
).OnElements("tbody", "tfoot")
}

func (p *Policy) AllowIFrames(vals ...SandboxValue) {
p.AllowAttrs("sandbox").OnElements("iframe")

p.RequireSandboxOnIFrame(vals...)
}
2 changes: 2 additions & 0 deletions policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ func (p *Policy) AllowURLSchemeWithCustomPolicy(
return p
}

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

Expand Down

0 comments on commit 5638f90

Please sign in to comment.