summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
Diffstat (limited to 'module/web')
-rw-r--r--module/web/cnl/views.py41
-rw-r--r--module/web/settings.py9
2 files changed, 18 insertions, 32 deletions
diff --git a/module/web/cnl/views.py b/module/web/cnl/views.py
index c2e95151c..516a67442 100644
--- a/module/web/cnl/views.py
+++ b/module/web/cnl/views.py
@@ -90,36 +90,27 @@ def addcrypted2(request):
jk = request.POST["jk"]
crypted = base64.standard_b64decode(unquote(crypted.replace(" ", "+")))
- try:
- import spidermonkey
- rt = spidermonkey.Runtime()
- cx = rt.new_context()
- jk = cx.execute("%s f()" % jk)
- except ImportError:
- if settings.JS:
- import subprocess
- jk = jk.replace("'", '"')
- cmd = settings.JS + ["-e", "%s ;print(f());" % jk ]
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
- jk = p.stdout.read().strip()
+ if settings.JS:
+ jk = "%s f()" % jk
+ jk = settings.JS.eval(jk)
- else:
- try:
- jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
- except:
- ## Test for some known js functions to decode
- if jk.find("dec") > -1 and jk.find("org") > -1:
- org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
- jk = list(org)
- jk.reverse()
- jk = "".join(jk)
- else:
- print "Could not decrypt key, please install py-spidermonkey or other js engine"
+ else:
+ try:
+ jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
+ except:
+ ## Test for some known js functions to decode
+ if jk.find("dec") > -1 and jk.find("org") > -1:
+ org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
+ jk = list(org)
+ jk.reverse()
+ jk = "".join(jk)
+ else:
+ print "Could not decrypt key, please install py-spidermonkey or ossp-js"
try:
Key = binascii.unhexlify(jk)
except:
- print "Could not decrypt key, please install py-spidermonkey or other js engine"
+ print "Could not decrypt key, please install py-spidermonkey or ossp-js"
return JsonResponse("failed", request)
IV = Key
diff --git a/module/web/settings.py b/module/web/settings.py
index 515117860..4dfe50fdc 100644
--- a/module/web/settings.py
+++ b/module/web/settings.py
@@ -55,13 +55,8 @@ except:
PYLOAD = xmlrpclib.ServerProxy(server_url, allow_none=True)
-try:
- import subprocess
- subprocess.Popen(["js", "-v"], bufsize=-1,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- JS = ["js"]
-except:
- JS = []
-
+from module.JsEngine import JsEngine
+JS = JsEngine()
TEMPLATE = config.get('webinterface','template')
DL_ROOT = os.path.join(PYLOAD_DIR, config.get('general','download_folder'))