From d1e66d2b53110fa653e9c0ceb35dbf611ad1e58b Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Fri, 15 Mar 2024 16:43:14 +0100 Subject: [PATCH] Fix crash in "Start with uppercase after colon" - thx Rouzax :) Related to #8029 --- src/Test/FixCommonErrors/FixCommonErrorsTest.cs | 11 +++++++++++ .../FixStartWithUppercaseLetterAfterColon.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Test/FixCommonErrors/FixCommonErrorsTest.cs b/src/Test/FixCommonErrors/FixCommonErrorsTest.cs index 85d4a6578..01ebbd2b7 100644 --- a/src/Test/FixCommonErrors/FixCommonErrorsTest.cs +++ b/src/Test/FixCommonErrors/FixCommonErrorsTest.cs @@ -2126,6 +2126,17 @@ namespace Test.FixCommonErrors } } + [TestMethod] + public void StartWithUppercaseAfterColon5() + { + using (var target = GetFixCommonErrorsLib()) + { + InitializeFixCommonErrorsLine(target, "TRANSLATION FROM FRENCH:"); + new FixStartWithUppercaseLetterAfterColon().Fix(_subtitle, new EmptyFixCallback()); + Assert.AreEqual("TRANSLATION FROM FRENCH:", _subtitle.Paragraphs[0].Text); + } + } + #endregion Start with upppercase after colon #region Fix Music Notation diff --git a/src/libse/Forms/FixCommonErrors/FixStartWithUppercaseLetterAfterColon.cs b/src/libse/Forms/FixCommonErrors/FixStartWithUppercaseLetterAfterColon.cs index 8628eee21..ba720d7ad 100644 --- a/src/libse/Forms/FixCommonErrors/FixStartWithUppercaseLetterAfterColon.cs +++ b/src/libse/Forms/FixCommonErrors/FixStartWithUppercaseLetterAfterColon.cs @@ -42,7 +42,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors // skip white space before formatting while (k < len && text[k] == ' ') k++; // skip formatting e.g: , ,... - while (k < len && text[k] == '<' || text[k] == '{') + while (k < len && (text[k] == '<' || text[k] == '{')) { var closingPair = GetClosingPair(text[k]); var closeIdx = text.IndexOf(closingPair, k + 1);