[gnome-subtitles] Simplified MPSub format regex not to hang with a test file (due to backtracking)



commit a279d978afdce8e7ef39fa112e6551d953c68181
Author: Pedro Castro <mail pedrocastro org>
Date:   Sat Feb 5 22:51:55 2011 +0000

    Simplified MPSub format regex not to hang with a test file (due to backtracking)

 .../IO/SubtitleFormats/SubtitleFormatMPSub.cs      |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs
index 697bcb4..2a51150 100644
--- a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of SubLib.
- * Copyright (C) 2006-2008 Pedro Castro
+ * Copyright (C) 2006-2008,2011 Pedro Castro
  *
  * SubLib is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ internal class SubtitleFormatMPSub : SubtitleFormat {
 		extensions = new string[] { "sub" };
 		lineBreak = "\n";
 
-		format = @"TITLE\s*=(\n?(?!FORMAT).*(?!FORMAT))*[.\n]FORMAT\s*=\s*(TIME|\d+)\s*(\n?(?!\d+(.\d+)?[^\d\n]+\d+(.\d+)?).*(?!\d+(.\d+)?[^\d\n]+\d+(.\d+)?))*[.\n]\d+(.\d+)?[^\d\n]+\d+(.\d+)?";
+		format = @"TITLE\s*=.*\n(.*\n)*FORMAT\s*=.*\n(.*\n)*[ \f\r\t\v]*\n\d+(\.\d+)? \d+(\.\d+)?\s+.+";
 
 		subtitleInTimesMode = @"(?<StartElapsedTime>\d+(\.\d*)?)[^\d\n](?<EndElapsedTime>\d+(\.\d*)?).*(?<Text>(\n?.*(?!\n[ \f\r\t\v]*\n))*.)";
 		subtitleInFramesMode = @"(?<StartElapsedFrames>\d+)[^\d\n](?<EndElapsedFrames>\d+).*(?<Text>(\n?.*(?!\n[ \f\r\t\v]*\n))*.)";



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]