Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
VTT parsing - Allow hour section that isn't 2 digits
- Allow more than 2 digits for extremely long videos
- Although the spec says it must be 2+ and so single digit times (e.g. 1:02:24.000 --> 1:04:48.000) are invalid, allow these too as it's unambiguous what was intended and easy to handle
  • Loading branch information
richard-smith-preservica authored Jul 8, 2025
commit ebc90562bb6a00601e42498297ffe559020e539c
4 changes: 3 additions & 1 deletion scripts/webvtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,9 @@
}
var timestamp = cut(state, nextSpace);

var results = /((\d\d):)?((\d\d):)(\d\d).(\d\d\d)|(\d+).(\d\d\d)/.exec(timestamp);
// The spec requires exactly 2 characters for minutes and seconds, and 2+ for hours,
// but some VTT generation creates 1 digit hour times (e.g. "1:02:24.000 --> 1:04:48.000") and it seems harmless to allow that here
var results = /((\d+):)?((\d\d):)(\d\d).(\d\d\d)|(\d+).(\d\d\d)/.exec(timestamp);

if (!results) {
state.error = 'Unable to parse timestamp';
Expand Down