This commit is contained in:
Michael Ganss
2019-01-17 12:52:36 +01:00
parent f4eeace29f
commit cabae353e8
2 changed files with 8 additions and 3 deletions

View File

@@ -538,6 +538,7 @@ namespace Ganss.XSS
}
// sanitize the style attribute
var oldStyleEmpty = string.IsNullOrEmpty(tag.GetAttribute("style"));
SanitizeStyle(tag, baseUrl);
var checkClasses = AllowedCssClasses != null;
@@ -564,9 +565,9 @@ namespace Ganss.XSS
if (!tag.ClassList.Any())
RemoveAttribute(tag, attribute, RemoveReason.ClassAttributeEmpty);
}
else if (string.IsNullOrEmpty(attribute.Value))
else if (!oldStyleEmpty && attribute.Name == "style" && string.IsNullOrEmpty(attribute.Value))
{
tag.RemoveAttribute(attribute.Name);
RemoveAttribute(tag, attribute, RemoveReason.StyleAttributeEmpty);
}
}
}

View File

@@ -32,6 +32,10 @@
/// <summary>
/// The class attribute is empty
/// </summary>
ClassAttributeEmpty
ClassAttributeEmpty,
/// <summary>
/// The style attribute is empty
/// </summary>
StyleAttributeEmpty,
}
}