Skip to content

Commit 078c4be

Browse files
authored
Merge pull request #138 from kiwiz/main
Fix incorrect handling of iframe SandboxValues
2 parents ce0adc5 + 1d1aa60 commit 078c4be

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ func (p *Policy) AllowURLSchemeWithCustomPolicy(
707707
func (p *Policy) RequireSandboxOnIFrame(vals ...SandboxValue) {
708708
p.requireSandboxOnIFrame = make(map[string]bool)
709709

710-
for val := range vals {
710+
for _, val := range vals {
711711
switch SandboxValue(val) {
712712
case SandboxAllowDownloads:
713713
p.requireSandboxOnIFrame["allow-downloads"] = true

sanitize_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,10 +1874,10 @@ func TestIssue107(t *testing.T) {
18741874
func TestIFrameSandbox(t *testing.T) {
18751875
p := NewPolicy()
18761876
p.AllowAttrs("sandbox").OnElements("iframe")
1877-
p.RequireSandboxOnIFrame(SandboxAllowDownloads)
1877+
p.RequireSandboxOnIFrame(SandboxAllowForms, SandboxAllowPopups)
18781878

1879-
in := `<iframe src="http://example.com" sandbox="allow-forms allow-downloads allow-downloads"></iframe>`
1880-
expected := `<iframe sandbox="allow-downloads"></iframe>`
1879+
in := `<iframe src="http://example.com" sandbox="allow-forms allow-downloads allow-downloads allow-popups"></iframe>`
1880+
expected := `<iframe sandbox="allow-forms allow-popups"></iframe>`
18811881
out := p.Sanitize(in)
18821882
if out != expected {
18831883
t.Errorf(

0 commit comments

Comments
 (0)