From f6c95dccf992cada8c4c415ed80c0742ca792d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 5 Apr 2018 18:24:58 +0200 Subject: [PATCH] [cloudflare] fix bypass procedure Cloudflare challenges, at least for kissmanga and readcomiconline, now use slightly different Javascript expressions. Instead of a single value per expression, they now have a numerator and a denominator of a fractional value, which in the end gets truncated to 10 decimal places. --- gallery_dl/cloudflare.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gallery_dl/cloudflare.py b/gallery_dl/cloudflare.py index 7ca8321a..ab0c3d7f 100644 --- a/gallery_dl/cloudflare.py +++ b/gallery_dl/cloudflare.py @@ -61,11 +61,18 @@ def solve_jschl(url, page): value = evaluate_expression(expr[vlength+2:]) solution = func(solution, value) elif expr.startswith("a.value"): - return solution + len(urllib.parse.urlsplit(url).netloc) + solution += len(urllib.parse.urlsplit(url).netloc) + if ".toFixed(" in expr: + solution = "{:.10f}".format(solution) + return solution def evaluate_expression(expr): """Evaluate a Javascript expression for the challenge""" + if "/" in expr: + num, _, denom = expr.partition("/") + return evaluate_expression(num) / evaluate_expression(denom) + stack = [] ranges = [] value = ""