From 137fc82fa834fef3560f9c58af5276896eaf2fb1 Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Wed, 11 May 2022 06:47:09 +0200 Subject: [PATCH] Use HTTP if no protocol is included in URL (fixes #22) --- calibre-plugin/libadobe.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/calibre-plugin/libadobe.py b/calibre-plugin/libadobe.py index d47618d..2b59ac8 100644 --- a/calibre-plugin/libadobe.py +++ b/calibre-plugin/libadobe.py @@ -319,6 +319,14 @@ def sendPOSTHTTPRequest(URL, document, type, returnRC = False): ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE + # Make sure URL has a protocol + # Some vendors (see issue #22) apparently don't include "http://" in some of their URLs. + # Python returns an error when it encounters such a URL, so just add that prefix if it's not present. + + if not "://" in URL: + print("Provider is using malformed URL %s, fixing." % (URL)) + URL = "http://" + URL + req = ulib.Request(url=URL, headers=headers, data=document) try: handler = ulib.urlopen(req, context=ctx)