From 34ddf0c18e6dd815d103552bf4013c41bd3a559c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 9 Jun 2018 23:57:00 +0100 Subject: Fix bad parsing of ASS lines embedded into FFmpeg files and containing commas; backport of f3db6f37c85352ad7631078907439ce8ff151b3d. --- src/lib/ffmpeg_decoder.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index ea41acf23..7b305ee15 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -678,16 +678,24 @@ FFmpegDecoder::decode_ass_subtitle (string ass, ContentTime from) produces a single format of Dialogue: lines... */ - vector bits; - split (bits, ass, is_any_of (",")); - if (bits.size() < 10) { + int commas = 0; + string text; + for (size_t i = 0; i < ass.length(); ++i) { + if (commas < 9 && ass[i] == ',') { + ++commas; + } else if (commas == 9) { + text += ass[i]; + } + } + + if (text.empty ()) { return; } sub::RawSubtitle base; list raw = sub::SSAReader::parse_line ( base, - bits[9], + text, _ffmpeg_content->video->size().width, _ffmpeg_content->video->size().height ); -- cgit v1.2.3