HtmlToEntities tolerate unclosed &.. html entities

This commit is contained in:
Wizou 2025-09-21 01:55:11 +02:00
parent 253249e06a
commit 4578dea3a3

View file

@ -378,15 +378,15 @@ namespace TL
end = offset + 1; end = offset + 1;
if (end < sb.Length && sb[end] == '#') end++; if (end < sb.Length && sb[end] == '#') end++;
while (end < sb.Length && sb[end] is >= 'a' and <= 'z' or >= 'A' and <= 'Z' or >= '0' and <= '9') end++; while (end < sb.Length && sb[end] is >= 'a' and <= 'z' or >= 'A' and <= 'Z' or >= '0' and <= '9') end++;
if (end >= sb.Length || sb[end] != ';') break; var html = HttpUtility.HtmlDecode(end >= sb.Length || sb[end] != ';'
var html = HttpUtility.HtmlDecode(sb.ToString(offset, end - offset + 1)); ? sb.ToString(offset, end - offset) + ";" : sb.ToString(offset, ++end - offset));
if (html.Length == 1) if (html.Length == 1)
{ {
sb[offset] = html[0]; sb[offset] = html[0];
sb.Remove(++offset, end - offset + 1); sb.Remove(++offset, end - offset);
} }
else else
offset = end + 1; offset = end;
} }
else if (c == '<') else if (c == '<')
{ {