From b0c8aa0a1462156ecee8c7cab4467206f3ee4f50 Mon Sep 17 00:00:00 2001 From: niksedk Date: Wed, 3 Nov 2021 14:30:52 +0100 Subject: [PATCH] Ignore insane hours in TTML 1 - thx snakeLo :) Related to #5442 --- src/libse/SubtitleFormats/TimedText10.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libse/SubtitleFormats/TimedText10.cs b/src/libse/SubtitleFormats/TimedText10.cs index 826b6d246..2e2b8de48 100644 --- a/src/libse/SubtitleFormats/TimedText10.cs +++ b/src/libse/SubtitleFormats/TimedText10.cs @@ -1033,6 +1033,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats return string.Empty; } + private static Regex _endsWithTreeDigits = new Regex(@"\d\d\d$"); private static bool IsFrames(string timeCode) { if (timeCode.Length == 12 && (timeCode[8] == '.' || timeCode[8] == ',')) // 00:00:08.292 or 00:00:08,292 @@ -1045,6 +1046,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats return false; } + if (_endsWithTreeDigits.IsMatch(timeCode)) + { + return false; + } + return true; } @@ -1287,7 +1293,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource = "frames"; return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), FramesToMillisecondsMax999(int.Parse(parts[3]))); } - return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), parts.Length > 3 ? int.Parse(parts[3]) : 0); + + var hours = int.Parse(parts[0]); + if (hours > 99) + { + hours = 0; + } + + return new TimeCode(hours, int.Parse(parts[1]), int.Parse(parts[2]), parts.Length > 3 ? int.Parse(parts[3]) : 0); } public override List AlternateExtensions => new List { ".itt", ".dfxp", ".ttml" };