Allow garbage after the timestamp in SRT files. Updates #1614.

This commit is contained in:
Thomas Goyne 2013-06-22 07:47:51 -07:00
parent 7c7cfc79e6
commit 135133e4c2

View file

@ -384,13 +384,13 @@ void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename,
state = STATE_TIMESTAMP; state = STATE_TIMESTAMP;
break; break;
} }
if (regex_match(text_line, timestamp_match, timestamp_regex)) if (regex_search(text_line, timestamp_match, timestamp_regex))
goto found_timestamps; goto found_timestamps;
throw SRTParseError(str(boost::format("Parsing SRT: Expected subtitle index at line %d") % line_num), 0); throw SRTParseError(str(boost::format("Parsing SRT: Expected subtitle index at line %d") % line_num), 0);
case STATE_TIMESTAMP: case STATE_TIMESTAMP:
if (!regex_match(text_line, timestamp_match, timestamp_regex)) if (!regex_search(text_line, timestamp_match, timestamp_regex))
throw SRTParseError(str(boost::format("Parsing SRT: Expected timestamp pair at line %d") % line_num), 0); throw SRTParseError(str(boost::format("Parsing SRT: Expected timestamp pair at line %d") % line_num), 0);
found_timestamps: found_timestamps:
if (line) { if (line) {
@ -443,7 +443,7 @@ found_timestamps:
state = STATE_TIMESTAMP; state = STATE_TIMESTAMP;
break; break;
} }
if (regex_match(text_line, timestamp_match, timestamp_regex)) if (regex_search(text_line, timestamp_match, timestamp_regex))
goto found_timestamps; goto found_timestamps;
// assume it's a continuation of the subtitle text // assume it's a continuation of the subtitle text