Fix HtmlEntity.DeEntitize duplicating '#' on invalid numeric entities
When a numeric character reference (&#...;) fails to parse, the catch block restored the text as "&#" + e where e already begins with '#', producing a doubled '#' (for example "&#foo;" became "&##foo;"). Restore the original text as "&" + e + ";" to match the named-entity fallback and keep DeEntitize idempotent for unparseable numeric entities.
This commit is contained in:
1 parent
8fcdf400eb
commit
56dba32abf
2 files changed
+27
-1
No files matched your search
@@ -663,7 +663,8 @@ namespace HtmlAgilityPack
|
||||
}
|
||||
catch
|
||||
{
|
||||
sb.Append("&#" + e + ";");
|
||||
// 'e' already starts with '#', so prepending "&#" would duplicate it.
|
||||
sb.Append("&" + e + ";");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user