An invalid entity got a second #
HtmlEntity.DeEntitize turned &#foo; into &##foo; and &#xGG; into &##xGG;. When the number could not be parsed, the catch block prepended &# to a value that already started with #, so the function damaged text it was meant to leave alone.
The original text restored exactly
The catch block now prepends only &, the same way the named-entity branch already did. An xUnit test covers invalid entities, also inside surrounding text, and checks that A, A and & still decode.