diff --git a/cursepy/__init__.py b/cursepy/__init__.py index 182588b..84b77d8 100644 --- a/cursepy/__init__.py +++ b/cursepy/__init__.py @@ -9,5 +9,5 @@ # Define some metadata here: -__version__ = '1.3.0' +__version__ = '1.3.1' __author__ = 'Owen Cochell' diff --git a/cursepy/proto.py b/cursepy/proto.py index d07a395..2f59bb7 100644 --- a/cursepy/proto.py +++ b/cursepy/proto.py @@ -8,13 +8,12 @@ import socket from urllib.request import urlopen, Request -from urllib.parse import urlencode +from urllib.parse import urlencode, quote, urlsplit, urlunsplit from http.client import HTTPResponse from typing import Optional class BaseProtocol(object): - """ Base protocol implementation - All child protocols must inherit this class! @@ -169,7 +168,6 @@ def write(self, byts: bytes): class URLProtocol(BaseProtocol): - """ URLProtocol - Gets information via HTTP. @@ -327,6 +325,8 @@ def _request_build(self, url: str, data: Optional[dict]=None, heads: Optional[di We point the request at the given url, add content headers, and add the given data. + We also do necessary quoting on the url path, + so our urls are valid. :param url: URL of the request :type url: str @@ -352,6 +352,10 @@ def _request_build(self, url: str, data: Optional[dict]=None, heads: Optional[di heads = {} - # Make and return the request: + # Make and return the request, do some quoting on the path only: + + split = urlsplit(url) + + split = split._replace(path=quote(split.path)) - return Request(url, data=encoded_data, headers={**self.headers, **heads}) + return Request(urlunsplit(split), data=encoded_data, headers={**self.headers, **heads}) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index daa2810..4512850 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -2,6 +2,14 @@ Changelog ========= +1.3.1 +===== + +Bug Fixes +--------- + +* We now properly quote the path section of any URLs given to the URLProtocol + 1.3.0 ====== diff --git a/docs/source/conf.py b/docs/source/conf.py index 1e52679..d050984 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,7 +18,7 @@ # -- Project information ----------------------------------------------------- project = 'cursepy' -copyright = '2021, Owen Cochell' +copyright = '2022, Owen Cochell' author = 'Owen Cochell' # The full version, including alpha/beta/rc tags