From 76df628b13434f9d24e71b97c8c219c31504be2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 27 Apr 2019 16:22:42 +0200 Subject: [PATCH] rewrite invalid cloudflare redirect locations After solving a challenge on komikcast.com, cloudflare would redirect to https:/komikcast.com (with only one '/') when testing on TravisCI. --- gallery_dl/cloudflare.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gallery_dl/cloudflare.py b/gallery_dl/cloudflare.py index 71193302..b9bf32da 100644 --- a/gallery_dl/cloudflare.py +++ b/gallery_dl/cloudflare.py @@ -59,8 +59,11 @@ def solve_challenge(session, response, kwargs): log.debug("Headers:\n%s", cf_response.headers) log.debug("Content:\n%s", cf_response.text) raise exception.StopExtraction() + if location[0] == "/": location = root + location + else: + location = re.sub(r"(https?):/(?!/)", r"\1://", location) for cookie in cf_response.cookies: if cookie.name == "cf_clearance":