From 3097ca162def6e20c94960c9da3f9932d044085f Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Wed, 29 Jul 2009 01:59:12 +0000 Subject: [PATCH] Handle ASS files with missing [Script Info] header better, updates #440. This should get some additional regression testing before the bug is closed and the fix backported to 2.1.8. Originally committed to SVN as r3308. --- aegisub/src/subtitle_format_ass.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aegisub/src/subtitle_format_ass.cpp b/aegisub/src/subtitle_format_ass.cpp index 390a98811..0592477c8 100644 --- a/aegisub/src/subtitle_format_ass.cpp +++ b/aegisub/src/subtitle_format_ass.cpp @@ -96,6 +96,13 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) { // Reads line wxbuffer = file.ReadLineFromFile(); + // Make sure that the first non-blank non-comment non-group-header line + // is really [Script Info] + if (curgroup.IsEmpty() && !wxbuffer.IsEmpty() && wxbuffer[0] != _T(';') && wxbuffer[0] != _T('[')) { + curgroup = _T("[Script Info]"); + lasttime = AddLine(curgroup,curgroup,lasttime,version,&curgroup); + } + // Convert v4 styles to v4+ styles if (!wxbuffer.IsEmpty() && wxbuffer[0] == _T('[')) { // Ugly hacks to allow intermixed v4 and v4+ style sections