From 119690ec5153e2b4b8c3516bc00d46e52b704fac Mon Sep 17 00:00:00 2001 From: niksedk Date: Mon, 16 Aug 2021 20:22:01 +0200 Subject: [PATCH] Allow bad end font tag when removing formatting --- src/libse/Common/HtmlUtil.cs | 4 +++- src/ui/Forms/Main.cs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libse/Common/HtmlUtil.cs b/src/libse/Common/HtmlUtil.cs index bdf70d447..2b0bce2d6 100644 --- a/src/libse/Common/HtmlUtil.cs +++ b/src/libse/Common/HtmlUtil.cs @@ -472,7 +472,9 @@ namespace Nikse.SubtitleEdit.Core.Common } } if ((next == 'f' || next == 'F') && s.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) // + next == '/' && (nextNext == 'f' || nextNext == 'F') && s.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) || // + next == ' ' && nextNext == '/' && s.Substring(i).StartsWith("< /font>", StringComparison.OrdinalIgnoreCase) || // < /font> + next == '/' && nextNext == ' ' && s.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) // { inside = true; continue; diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 4e523abb8..18c39e74f 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -30609,6 +30609,22 @@ namespace Nikse.SubtitleEdit.Forms { s = s.Remove(endIndex, 7); } + else + { + endIndex = s.IndexOf("< /font>", match.Index - 5, StringComparison.OrdinalIgnoreCase); + if (endIndex >= 0) + { + s = s.Remove(endIndex, 7); + } + else + { + endIndex = s.IndexOf("", match.Index - 5, StringComparison.OrdinalIgnoreCase); + if (endIndex >= 0) + { + s = s.Remove(endIndex, 7); + } + } + } } else if (s.Length > match.Index + 1 && s[match.Index + 1] == '>') {