From 4c25e0b1c065a12549cc3fcf482547a6df072d00 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 9 Apr 2016 14:52:31 +0530 Subject: [PATCH] Handle URLs passed with %xx escape. E.g.: "https://linuxreference.wordpress.com/2010/12/28/25-even-more-%E2%80%93-sick-linux-commands/" --- buku | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/buku b/buku index 9e1ae50..081cef9 100755 --- a/buku +++ b/buku @@ -25,7 +25,7 @@ import readline import webbrowser import html.parser as HTMLParser from http.client import HTTPConnection, HTTPSConnection -from urllib.parse import urljoin, unquote +from urllib.parse import urljoin, quote, unquote import signal import shutil @@ -214,6 +214,12 @@ def getPageResp(url, redir=False): print("server: [%s]" % server) print("URL: [%s]" % url) + # Handle URLs passed with %xx escape + try: + url.encode('ascii') + except: + url = quote(url) + urlconn.request("GET", url) resp = urlconn.getresponse() return (urlconn, resp)