mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
test(sanitizer): add test case to cover Vimeo iframe rewrite without query string
This commit is contained in:
parent
27015a5e34
commit
0b001edbf6
1 changed files with 12 additions and 2 deletions
|
@ -818,13 +818,23 @@ func TestReplaceYoutubeURLWithCustomURL(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReplaceIframeVimedoDNTURL(t *testing.T) {
|
func TestVimeoIframeRewriteWithQueryString(t *testing.T) {
|
||||||
input := `<iframe src="https://player.vimeo.com/video/123456?title=0&byline=0"></iframe>`
|
input := `<iframe src="https://player.vimeo.com/video/123456?title=0&byline=0"></iframe>`
|
||||||
expected := `<iframe src="https://player.vimeo.com/video/123456?title=0&byline=0&dnt=1" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" loading="lazy"></iframe>`
|
expected := `<iframe src="https://player.vimeo.com/video/123456?title=0&byline=0&dnt=1" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" loading="lazy"></iframe>`
|
||||||
output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
|
output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
|
||||||
|
|
||||||
if expected != output {
|
if expected != output {
|
||||||
t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
|
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestVimeoIframeRewriteWithoutQueryString(t *testing.T) {
|
||||||
|
input := `<iframe src="https://player.vimeo.com/video/123456"></iframe>`
|
||||||
|
expected := `<iframe src="https://player.vimeo.com/video/123456?dnt=1" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" loading="lazy"></iframe>`
|
||||||
|
output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
|
||||||
|
|
||||||
|
if expected != output {
|
||||||
|
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue