Use initSafeStandardsObjects()

This commit is contained in:
wb9688 2020-08-15 17:08:07 +02:00
parent de8edbe7a5
commit 7657c2ed1a
1 changed files with 5 additions and 6 deletions

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();
} }