1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-22 17:18:37 +00:00

Sandbox iframes when sanitizing.

Updated iframe unit tests.

Refactored sanitizer.getExtraAttributes() to use `switch` instead of multiple `if` statements.
This commit is contained in:
dzaikos 2018-07-02 03:16:27 -04:00 committed by Frédéric Guillot
parent c3628813c6
commit 7d4a195519
2 changed files with 13 additions and 12 deletions

View file

@ -131,15 +131,16 @@ func sanitizeAttributes(baseURL, tagName string, attributes []html.Attribute) ([
}
func getExtraAttributes(tagName string) ([]string, []string) {
if tagName == "a" {
switch tagName {
case "a":
return []string{"rel", "target", "referrerpolicy"}, []string{`rel="noopener noreferrer"`, `target="_blank"`, `referrerpolicy="no-referrer"`}
}
if tagName == "video" || tagName == "audio" {
case "video", "audio":
return []string{"controls"}, []string{"controls"}
case "iframe":
return []string{"sandbox"}, []string{`sandbox="allow-scripts allow-same-origin"`}
default:
return nil, nil
}
return nil, nil
}
func isValidTag(tagName string) bool {