From 57ebbcdc9ed66765890c02426ed3ed4d06c4cb83 Mon Sep 17 00:00:00 2001 From: "Warren R. Bank" Date: Thu, 26 Dec 2024 13:20:04 -0800 Subject: [PATCH] restrict milliseconds field in SRT time codes to 3 digits --- .../androidx/media3/extractor/text/subrip/SubripParser.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/text/subrip/SubripParser.java b/libraries/extractor/src/main/java/androidx/media3/extractor/text/subrip/SubripParser.java index da98660d3c7..d7d114e6918 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/text/subrip/SubripParser.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/text/subrip/SubripParser.java @@ -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;