Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitdc0459e

Browse files
committed
chore(editor): add iframe sanitizer case
1 parent2a76015 commitdc0459e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎lib/helper/converter/html_sanitizer.ex‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ defmodule Helper.Converter.HtmlSanitizer do
3636
Meta.allow_tag_with_these_attributes("ol",["class"])
3737
Meta.allow_tag_with_these_attributes("li",["class"])
3838

39+
Meta.allow_tag_with_these_attributes("iframe",[
40+
"sandbox",
41+
"allow-same-origin",
42+
"allow-popups",
43+
"allow-presentation",
44+
"src",
45+
"frameborder",
46+
"allow",
47+
"allowfullscreen",
48+
"style"
49+
])
50+
3951
Meta.strip_everything_not_covered()
4052
end
4153

‎test/helper/converter/html_sanitizer_test.exs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,15 @@ defmodule GroupherServer.Test.Helper.Converter.HtmlSanitizer do
4747
html="This <form>is</form> <i class=\"cool-look\" other=\"other\">text</i>"
4848
assertSanitizer.sanitize(html)=="This is <i>text</i>"
4949
end
50+
51+
@tag:wip2
52+
test"allow iframe with valid attr"do
53+
html="""
54+
<iframe sandbox="allow-scripts allow-same-origin allow-presentation" src="addr" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen="" style="width: 100%; height: 300px;" invalidprops></iframe>
55+
"""
56+
57+
assertSanitizer.sanitize(html)==
58+
"<iframe sandbox=\"allow-scripts allow-same-origin allow-presentation\" src=\"addr\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\" style=\"width: 100%; height: 300px;\"></iframe>\n"
59+
end
5060
end
5161
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp