|
6 | 6 | import org.schabi.newpipe.extractor.utils.jsextractor.JavaScriptExtractor; |
7 | 7 |
|
8 | 8 | import javax.annotation.Nonnull; |
| 9 | +import java.util.regex.Pattern; |
9 | 10 |
|
10 | 11 | /** |
11 | 12 | * Utility class to get the signature timestamp of YouTube's base JavaScript player and deobfuscate |
@@ -94,7 +95,7 @@ static String getDeobfuscationCode(@Nonnull final String javaScriptPlayerCode) |
94 | 95 | + deobfuscationFunctionName |
95 | 96 | + "(a);}"; |
96 | 97 |
|
97 | | - return helperObject + deobfuscationFunction + callerFunction; |
| 98 | + return helperObject + deobfuscationFunction + ";" + callerFunction; |
98 | 99 | } catch (final Exception e) { |
99 | 100 | throw new ParsingException("Could not parse deobfuscation function", e); |
100 | 101 | } |
@@ -124,25 +125,25 @@ private static String getDeobfuscateFunctionWithLexer( |
124 | 125 | @Nonnull final String deobfuscationFunctionName) throws ParsingException { |
125 | 126 | final String functionBase = deobfuscationFunctionName + "=function"; |
126 | 127 | return functionBase + JavaScriptExtractor.matchToClosingBrace( |
127 | | - javaScriptPlayerCode, functionBase) + ";"; |
| 128 | + javaScriptPlayerCode, functionBase); |
128 | 129 | } |
129 | 130 |
|
130 | 131 | @Nonnull |
131 | 132 | private static String getDeobfuscateFunctionWithRegex( |
132 | 133 | @Nonnull final String javaScriptPlayerCode, |
133 | 134 | @Nonnull final String deobfuscationFunctionName) throws ParsingException { |
134 | 135 | final String functionPattern = DEOBF_FUNC_REGEX_START |
135 | | - + deobfuscationFunctionName.replace("$", "\\$") |
| 136 | + + Pattern.quote(deobfuscationFunctionName) |
136 | 137 | + DEOBF_FUNC_REGEX_END; |
137 | | - return "var " + Parser.matchGroup1(functionPattern, javaScriptPlayerCode) + ";"; |
| 138 | + return "var " + Parser.matchGroup1(functionPattern, javaScriptPlayerCode); |
138 | 139 | } |
139 | 140 |
|
140 | 141 | @Nonnull |
141 | 142 | private static String getHelperObject(@Nonnull final String javaScriptPlayerCode, |
142 | 143 | @Nonnull final String helperObjectName) |
143 | 144 | throws ParsingException { |
144 | 145 | final String helperPattern = SIG_DEOBF_HELPER_OBJ_REGEX_START |
145 | | - + helperObjectName.replace("$", "\\$") |
| 146 | + + Pattern.quote(helperObjectName) |
146 | 147 | + SIG_DEOBF_HELPER_OBJ_REGEX_END; |
147 | 148 | return Parser.matchGroup1(helperPattern, javaScriptPlayerCode) |
148 | 149 | .replace("\n", ""); |
|
0 commit comments