mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
perf(sanitizer): use a switch-case instead of a map
This removes a heap allocation, and should be way faster. It also makes the code shorted/simpler.
This commit is contained in:
parent
e9d4a130fd
commit
237672a62c
1 changed files with 6 additions and 8 deletions
|
@ -180,12 +180,6 @@ var (
|
||||||
"hack": {}, // https://apps.apple.com/it/app/hack-for-hacker-news-reader/id1464477788?l=en-GB
|
"hack": {}, // https://apps.apple.com/it/app/hack-for-hacker-news-reader/id1464477788?l=en-GB
|
||||||
}
|
}
|
||||||
|
|
||||||
blockedTags = map[string]struct{}{
|
|
||||||
"noscript": {},
|
|
||||||
"script": {},
|
|
||||||
"style": {},
|
|
||||||
}
|
|
||||||
|
|
||||||
dataAttributeAllowedPrefixes = []string{
|
dataAttributeAllowedPrefixes = []string{
|
||||||
"data:image/avif",
|
"data:image/avif",
|
||||||
"data:image/apng",
|
"data:image/apng",
|
||||||
|
@ -537,8 +531,12 @@ func rewriteIframeURL(link string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isBlockedTag(tagName string) bool {
|
func isBlockedTag(tagName string) bool {
|
||||||
_, ok := blockedTags[tagName]
|
switch tagName {
|
||||||
return ok
|
case "noscript", "script", "style":
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sanitizeSrcsetAttr(baseURL, value string) string {
|
func sanitizeSrcsetAttr(baseURL, value string) string {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue