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.
This commit is contained in:
Niels Martin Hansen 2009-07-29 01:59:12 +00:00
parent 174c17309b
commit 3097ca162d

View file

@ -96,6 +96,13 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
// Reads line // Reads line
wxbuffer = file.ReadLineFromFile(); 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 // Convert v4 styles to v4+ styles
if (!wxbuffer.IsEmpty() && wxbuffer[0] == _T('[')) { if (!wxbuffer.IsEmpty() && wxbuffer[0] == _T('[')) {
// Ugly hacks to allow intermixed v4 and v4+ style sections // Ugly hacks to allow intermixed v4 and v4+ style sections