1
0
Fork 0
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:
jvoisin 2025-06-16 12:36:28 +02:00 committed by Frédéric Guillot
parent e9d4a130fd
commit 237672a62c

View file

@ -180,12 +180,6 @@ var (
"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{
"data:image/avif",
"data:image/apng",
@ -537,8 +531,12 @@ func rewriteIframeURL(link string) string {
}
func isBlockedTag(tagName string) bool {
_, ok := blockedTags[tagName]
return ok
switch tagName {
case "noscript", "script", "style":
return true
default:
return false
}
}
func sanitizeSrcsetAttr(baseURL, value string) string {