Fix #155
This commit is contained in:
@@ -538,6 +538,7 @@ namespace Ganss.XSS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sanitize the style attribute
|
// sanitize the style attribute
|
||||||
|
var oldStyleEmpty = string.IsNullOrEmpty(tag.GetAttribute("style"));
|
||||||
SanitizeStyle(tag, baseUrl);
|
SanitizeStyle(tag, baseUrl);
|
||||||
|
|
||||||
var checkClasses = AllowedCssClasses != null;
|
var checkClasses = AllowedCssClasses != null;
|
||||||
@@ -564,9 +565,9 @@ namespace Ganss.XSS
|
|||||||
if (!tag.ClassList.Any())
|
if (!tag.ClassList.Any())
|
||||||
RemoveAttribute(tag, attribute, RemoveReason.ClassAttributeEmpty);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The class attribute is empty
|
/// The class attribute is empty
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClassAttributeEmpty
|
ClassAttributeEmpty,
|
||||||
|
/// <summary>
|
||||||
|
/// The style attribute is empty
|
||||||
|
/// </summary>
|
||||||
|
StyleAttributeEmpty,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user