mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
test(sanitizer): enhance tests for image width and height attributes
This commit is contained in:
parent
8c3f280f32
commit
cb617ff6e0
2 changed files with 48 additions and 9 deletions
|
@ -303,14 +303,8 @@ func SanitizeHTML(baseURL, rawHTML string, sanitizerOptions *SanitizerOptions) s
|
|||
func sanitizeAttributes(parsedBaseUrl *url.URL, baseURL, tagName string, attributes []html.Attribute, sanitizerOptions *SanitizerOptions) ([]string, string) {
|
||||
var htmlAttrs, attrNames []string
|
||||
var err error
|
||||
var isImageLargerThanLayout bool
|
||||
var isAnchorLink bool
|
||||
|
||||
if tagName == "img" {
|
||||
imgWidth := getIntegerAttributeValue("width", attributes)
|
||||
isImageLargerThanLayout = imgWidth > 750
|
||||
}
|
||||
|
||||
for _, attribute := range attributes {
|
||||
if !isValidAttribute(tagName, attribute.Key) {
|
||||
continue
|
||||
|
@ -336,7 +330,12 @@ func sanitizeAttributes(parsedBaseUrl *url.URL, baseURL, tagName string, attribu
|
|||
continue
|
||||
}
|
||||
case "width", "height":
|
||||
if isImageLargerThanLayout || !isPositiveInteger(value) {
|
||||
if !isPositiveInteger(value) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Discard width and height attributes when width is larger than Miniflux layout (750px)
|
||||
if imgWidth := getIntegerAttributeValue("width", attributes); imgWidth > 750 {
|
||||
continue
|
||||
}
|
||||
case "srcset":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue