From 4905f74700a511c2b424e0c66e4a81da7ebb22f9 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 9 Sep 2022 10:49:26 +0200 Subject: [PATCH] [YouTube] Fix throttling parameter decryption on Android Escape the curly brace in the regular expression used to parse the throttling parameter decryption function to allow its compatibility on Android. --- .../services/youtube/YoutubeThrottlingDecrypter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java index d71754e0b..8160e6315 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java @@ -137,7 +137,10 @@ public final class YoutubeThrottlingDecrypter { @Nonnull private static String parseWithRegex(final String playerJsCode, final String functionName) throws Parser.RegexException { - final Pattern functionPattern = Pattern.compile(functionName + "=function(.*?};)\n", + // Escape the curly end brace to allow compatibility with Android's regex engine + // See https://stackoverflow.com/q/45074813 + //noinspection RegExpRedundantEscape + final Pattern functionPattern = Pattern.compile(functionName + "=function(.*?\\};)\n", Pattern.DOTALL); return validateFunction("function " + functionName