Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restrict milliseconds field in VTT and SRT text caption time codes to 3 digits #1999

Open
wants to merge 2 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ private static long parseTimecode(Matcher matcher, int groupOffset) {
timestampMs += Long.parseLong(Assertions.checkNotNull(matcher.group(groupOffset + 3))) * 1000;
@Nullable String millis = matcher.group(groupOffset + 4);
if (millis != null) {
if (millis.length() > 3) {
try {
millis = millis.substring(0, 3);
}
catch(IndexOutOfBoundsException e) {}
}
timestampMs += Long.parseLong(millis);
}
return timestampMs * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public static long parseTimestampUs(String timestamp) throws NumberFormatExcepti
}
value *= 1000;
if (parts.length == 2) {
if (parts[1].length() > 3) {
try {
parts[1] = parts[1].substring(0, 3);
}
catch(IndexOutOfBoundsException e) {}
}
value += Long.parseLong(parts[1]);
}
return value * 1000;
Expand Down