This project has moved and is read-only. For the latest updates, please go here.
9
Vote

Bug in HtmlEntity.DeEntitize in v1.4.6

description

DeEntitize will throw KeyNotFoundException when input text contains invalid characters such as "&$;".

Existing code

int code;
object o = _entityValue[entity.ToString()];
if (o == null)
{
// nope
sb.Append("&" + entity + ";");
}
else
{
// we found one
code = (int) o;
sb.Append(Convert.ToChar(code));
}


Suggested change

int code;

if (_entityValue.TryGetValue(entity.ToString(), out code))
{
sb.Append(Convert.ToChar(code));
}
else
{
sb.Append("&" + entity + ";");
}

comments