Merge pull request #387 from wb9688/init-safe-standard-objects

Use initSafeStandardsObjects()
This commit is contained in:
Tobias Groza 2020-08-26 21:25:46 +02:00 committed by GitHub
commit 070cd92857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -627,7 +627,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\(", "yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\(",
"\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\(" "\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\("
}; };
;
private volatile String decryptionCode = ""; private volatile String decryptionCode = "";
@ -788,16 +787,16 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} }
private String decryptSignature(String encryptedSig, String decryptionCode) throws DecryptException { private String decryptSignature(String encryptedSig, String decryptionCode) throws DecryptException {
Context context = Context.enter(); final Context context = Context.enter();
context.setOptimizationLevel(-1); context.setOptimizationLevel(-1);
Object result; final Object result;
try { try {
ScriptableObject scope = context.initStandardObjects(); final ScriptableObject scope = context.initSafeStandardObjects();
context.evaluateString(scope, decryptionCode, "decryptionCode", 1, null); context.evaluateString(scope, decryptionCode, "decryptionCode", 1, null);
Function decryptionFunc = (Function) scope.get("decrypt", scope); final Function decryptionFunc = (Function) scope.get("decrypt", scope);
result = decryptionFunc.call(context, scope, scope, new Object[]{encryptedSig}); result = decryptionFunc.call(context, scope, scope, new Object[]{encryptedSig});
} catch (Exception e) { } catch (Exception e) {
throw new DecryptException("could not get decrypt signature", e); throw new DecryptException("Could not get decrypt signature", e);
} finally { } finally {
Context.exit(); Context.exit();
} }