This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
TagHelperOutputExtensions.RemoveRange()
does not handle its attributes
parameter safely #2491
Closed
Description
the following code:
var attributes = tagHelperOutput.Attributes
.Where(item => item.Name.StartsWith("route-", StringComparison.OrdinalIgnoreCase));
tagHelperOutput.RemoveRange(attributes);
throw
s an InvalidOperationException
with Message == "Collection was modified; enumeration operation may not execute."
RemoveRange()
should use ToArray()
or ToList()
to avoid such issues in its for
loop.