Fix some small errors in SSA/ASS parsing.
authorCarl Hetherington <cth@carlh.net>
Sun, 19 Jun 2016 20:57:58 +0000 (21:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 19 Jun 2016 20:57:58 +0000 (21:57 +0100)
src/ssa_reader.cc
test/ssa_reader_test.cc

index c1614a8ce5f15d07b1d0b5716eff58776b31df2a..74d497a87d85049a456ddc7a25b25baea17713bc 100644 (file)
@@ -316,9 +316,9 @@ SSAReader::read (function<optional<string> ()> get_line)
 
                size_t const colon = line->find (":");
                SUB_ASSERT (colon != string::npos);
-               SUB_ASSERT (line->length() > colon + 1);
                string const type = line->substr (0, colon);
-               string const body = line->substr (colon + 2);
+               string body = line->substr (colon + 1);
+               trim (body);
 
                switch (part) {
                case INFO:
@@ -367,6 +367,10 @@ SSAReader::read (function<optional<string> ()> get_line)
                                        } else if (event_format[i] == "End") {
                                                sub.to = parse_time (event[i]);
                                        } else if (event_format[i] == "Style") {
+                                               /* libass trims leading '*'s from style names, commenting that
+                                                  "they seem to mean literally nothing".  Go figure...
+                                               */
+                                               trim_left_if (event[i], boost::is_any_of ("*"));
                                                SUB_ASSERT (styles.find(event[i]) != styles.end());
                                                Style style = styles[event[i]];
                                                sub.font = style.font_name;
index 46b5cb75600c010d003401afef027dedbdef633f..30f853829c7db864057e2f24cc55322e1023bf0c 100644 (file)
@@ -124,6 +124,7 @@ test (boost::filesystem::path p)
 BOOST_AUTO_TEST_CASE (ssa_reader_test2)
 {
        test ("DKH_UT_EN20160601def.ssa");
+       test ("dcpsubtest-en.ssa");
 }
 
 #define SUB_START(f, t) \