Add timeout for main win regex search - thx darksen/Janusz :)

This commit is contained in:
niksedk 2021-10-30 08:42:32 +02:00
parent 5fccab6a1f
commit 0ab42730ad
3 changed files with 19 additions and 3 deletions

View File

@ -37,6 +37,7 @@
* Improve drag'n'drop to list view with istm format - thx Zivko
* Ignore text between {} when spell checking ASSA/SSA - thx Omair
* Try avoid set mpv volume to 0 - thx Janusz
* Improve waveform move-element performance - thx Leon
* FIXED:
* Fix tag style converting from/to ASSA - thx von Suppé
* Fix "Title bar text" when translating - thx Andrebavila
@ -55,6 +56,7 @@
* Fix "Set start and set end of prev" when playing - thx Leon
* Fix "Set end minus gap, go to next and start next here" - thx Leon
* Fix for mpc-hc not showing video
* Add timeout for main win regex search - thx darksen/Janusz
3.6.2 (24th August 2021)

View File

@ -122,7 +122,7 @@ namespace Nikse.SubtitleEdit.Forms
{
try
{
_regEx = new Regex(RegexUtils.FixNewLine(searchText), RegexOptions.Compiled);
_regEx = new Regex(RegexUtils.FixNewLine(searchText), RegexOptions.Compiled, TimeSpan.FromSeconds(5));
DialogResult = DialogResult.OK;
}
catch (Exception exception)

View File

@ -85,7 +85,20 @@ namespace Nikse.SubtitleEdit.Logic
return -1;
}
var match = _regEx.Match(text, startIndex);
Match match;
try
{
match = _regEx.Match(text, startIndex);
}
catch (RegexMatchTimeoutException exception)
{
MessageBox.Show(exception.Message + Environment.NewLine +
Environment.NewLine +
"Input: " + exception.Input);
return -1;
}
if (match.Success)
{
string groupName = RegexUtils.GetRegExGroup(FindText);
@ -97,6 +110,7 @@ namespace Nikse.SubtitleEdit.Logic
FindTextLength = match.Length;
return match.Index;
}
return -1;
}
@ -393,7 +407,7 @@ namespace Nikse.SubtitleEdit.Logic
MessageBox.Show(LanguageSettings.Current.General.RegularExpressionIsNotValid);
return count;
}
_regEx = new Regex(findText);
_regEx = new Regex(findText, RegexOptions.None, TimeSpan.FromSeconds(5));
}
var comparison = GetComparison();
foreach (var p in subtitle.Paragraphs)