From 4578dea3a37f98767f48f1f362128969b6ccd198 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sun, 21 Sep 2025 01:55:11 +0200 Subject: [PATCH] HtmlToEntities tolerate unclosed &.. html entities --- src/Services.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Services.cs b/src/Services.cs index a83eed6..4b8cd9d 100644 --- a/src/Services.cs +++ b/src/Services.cs @@ -378,15 +378,15 @@ namespace TL end = offset + 1; 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++; - if (end >= sb.Length || sb[end] != ';') break; - var html = HttpUtility.HtmlDecode(sb.ToString(offset, end - offset + 1)); + var html = HttpUtility.HtmlDecode(end >= sb.Length || sb[end] != ';' + ? sb.ToString(offset, end - offset) + ";" : sb.ToString(offset, ++end - offset)); if (html.Length == 1) { sb[offset] = html[0]; - sb.Remove(++offset, end - offset + 1); + sb.Remove(++offset, end - offset); } else - offset = end + 1; + offset = end; } else if (c == '<') {