diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2011-04-14 20:57:43 +0100 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2011-04-14 21:00:52 +0100 |
commit | be3d1413b7984b7e9da23e991e63aa68e1b6aeca (patch) | |
tree | 6b8c9cd0297c39ae875d6a3970e8e53a2501c515 | |
parent | 1d020790efc2f85001aa4bed6c78e06840f0627e (diff) |
chapters: Permit invalid timestamp formats as previously output by Totem
Allow timestamps which consist only of the floating-point number of seconds
to be successfully parsed by the CMML parser, even if that number of seconds
is >= 60.0. This means Totem no longer falls over on the CMML files it was
previously outputting.
Closes: bgo#647513
-rw-r--r-- | src/plugins/chapters/totem-cmml-parser.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/chapters/totem-cmml-parser.c b/src/plugins/chapters/totem-cmml-parser.c index 59e9ada3..3b7447fc 100644 --- a/src/plugins/chapters/totem-cmml-parser.c +++ b/src/plugins/chapters/totem-cmml-parser.c @@ -314,7 +314,14 @@ totem_cmml_parse_npt (const gchar *str) return -1; if (G_UNLIKELY (m > 59 || m < 0)) return -1; - if (G_UNLIKELY (s >= 60.0 || s < 0.0)) + + /* We break slightly with the specifications here and allow seconds-only values greater than 60 seconds. + * (i.e. we allow "90" to be successfully parsed as 1.5 minutes and returned as 90 seconds, rather than + * returning an error because it's > 60). This is because Totem previously (incorrectly) wrote out timestamps + * in this (seconds only, potentially > 60) format; so for compatibility with CMML files written by older + * versions of Totem, we have to allow such formats. + * However, if either h or m is non-zero, we error out as before. */ + if (G_UNLIKELY ((h != 0 || m != 0) && (s >= 60.0 || s < 0.0))) return -1; return (h * 3600.0) + (m * 60.0) + s; |