From 9c1cc0cfdf2145f701d4c72f72cf75790584cb27 Mon Sep 17 00:00:00 2001 From: sblack-usu Date: Tue, 14 Oct 2025 10:25:10 -0600 Subject: [PATCH 1/5] remove url encoding, rely on default encoding from tools as needed --- hsclient/hydroshare.py | 10 +++++----- hsclient/utils.py | 14 -------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index 59ef710..72be7e5 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -51,7 +51,7 @@ from hsclient.json_models import ResourcePreview, User from hsclient.oauth2_model import Token -from hsclient.utils import attribute_filter, encode_resource_url, is_aggregation, main_file_type +from hsclient.utils import attribute_filter, is_aggregation, main_file_type import pkg_resources # part of setuptools VERSION = pkg_resources.get_distribution(__package__).version @@ -1429,7 +1429,7 @@ def upload_file(self, path, files, status_code=204): return self.post(path, files=files, status_code=status_code) def post(self, path, status_code, data=None, params={}, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.post(url, params=params, data=data, **kwargs) if response.status_code != status_code: raise Exception( @@ -1438,7 +1438,7 @@ def post(self, path, status_code, data=None, params={}, **kwargs): return response def put(self, path, status_code, data=None, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.put(url, data=data, **kwargs) if response.status_code != status_code: raise Exception( @@ -1447,7 +1447,7 @@ def put(self, path, status_code, data=None, **kwargs): return response def get(self, path, status_code, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.get(url, **kwargs) if response.status_code != status_code: raise Exception( @@ -1456,7 +1456,7 @@ def get(self, path, status_code, **kwargs): return response def delete(self, path, status_code, **kwargs): - url = encode_resource_url(self._build_url(path)) + url = self._build_url(path) response = self._session.delete(url, **kwargs) if response.status_code != status_code: raise Exception( diff --git a/hsclient/utils.py b/hsclient/utils.py index a8ef779..4275b06 100644 --- a/hsclient/utils.py +++ b/hsclient/utils.py @@ -52,20 +52,6 @@ def attribute_filter(o, key, value) -> bool: return attr == value -def encode_resource_url(url): - """ - URL encodes a full resource file/folder url. - :param url: a string url - :return: url encoded string - """ - import urllib - - parsed_url = urllib.parse.urlparse(url) - url_encoded_path = pathname2url(parsed_url.path) - encoded_url = parsed_url._replace(path=url_encoded_path).geturl() - return encoded_url - - def is_folder(path): """Checks for an extension to determine if the path is to a folder""" return splitext(path)[1] == '' From 854abac494c609e809c8aa130e7bdf0bd9240d95 Mon Sep 17 00:00:00 2001 From: sblack-usu Date: Wed, 15 Oct 2025 09:43:31 -0600 Subject: [PATCH 2/5] remove unquote --- hsclient/hydroshare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index 59ef710..22eb885 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -14,7 +14,7 @@ from posixpath import basename, dirname, join as urljoin, splitext from pprint import pformat from typing import Callable, Dict, List, TYPE_CHECKING, Union -from urllib.parse import quote, unquote, urlparse +from urllib.parse import unquote, urlparse from uuid import uuid4 from zipfile import ZipFile @@ -243,7 +243,7 @@ def _retrieve_checksums(self, path): # split string by lines, then split line by delimiter into a dict delimiter = " " data = { - quote(path): checksum for checksum, path in [line.split(delimiter) for line in file_str.split("\n") if line] + path: checksum for checksum, path in [line.split(delimiter) for line in file_str.split("\n") if line] } return data From 07389e8defedaea49b1a4b44164ed31bfc031c55 Mon Sep 17 00:00:00 2001 From: sblack-usu Date: Wed, 15 Oct 2025 09:52:29 -0600 Subject: [PATCH 3/5] remove unquote --- hsclient/hydroshare.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index 22eb885..e5e51f6 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -14,7 +14,7 @@ from posixpath import basename, dirname, join as urljoin, splitext from pprint import pformat from typing import Callable, Dict, List, TYPE_CHECKING, Union -from urllib.parse import unquote, urlparse +from urllib.parse import urlparse from uuid import uuid4 from zipfile import ZipFile @@ -173,12 +173,8 @@ def _files(self): if not file.path == self.metadata_path: if not str(file.path).endswith('/'): # checking for folders, shouldn't have to do this file_checksum_path = file.path.split(self._resource_path, 1)[1].strip("/") - file_path = unquote( - file_checksum_path.split( - "data/contents/", - )[1] - ) - f = File(file_path, unquote(file.path), self._checksums[file_checksum_path]) + file_path = file_checksum_path.split("data/contents/")[1] + f = File(file_path, file.path, self._checksums[file_checksum_path]) self._parsed_files.append(f) return self._parsed_files @@ -192,7 +188,7 @@ def populate_metadata(_aggr): self._parsed_aggregations = [] for file in self._map.describes.files: if is_aggregation(str(file)): - self._parsed_aggregations.append(Aggregation(unquote(file.path), self._hs_session, self._checksums)) + self._parsed_aggregations.append(Aggregation(file.path, self._hs_session, self._checksums)) # load metadata for all aggregations (metadata is needed to create any typed aggregation) with ThreadPoolExecutor() as executor: From 796226a2d1d07154bc3df806c9d900dce5101188 Mon Sep 17 00:00:00 2001 From: sblack-usu Date: Wed, 15 Oct 2025 09:54:09 -0600 Subject: [PATCH 4/5] Revert "remove unquote" This reverts commit 07389e8defedaea49b1a4b44164ed31bfc031c55. --- hsclient/hydroshare.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index e5e51f6..22eb885 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -14,7 +14,7 @@ from posixpath import basename, dirname, join as urljoin, splitext from pprint import pformat from typing import Callable, Dict, List, TYPE_CHECKING, Union -from urllib.parse import urlparse +from urllib.parse import unquote, urlparse from uuid import uuid4 from zipfile import ZipFile @@ -173,8 +173,12 @@ def _files(self): if not file.path == self.metadata_path: if not str(file.path).endswith('/'): # checking for folders, shouldn't have to do this file_checksum_path = file.path.split(self._resource_path, 1)[1].strip("/") - file_path = file_checksum_path.split("data/contents/")[1] - f = File(file_path, file.path, self._checksums[file_checksum_path]) + file_path = unquote( + file_checksum_path.split( + "data/contents/", + )[1] + ) + f = File(file_path, unquote(file.path), self._checksums[file_checksum_path]) self._parsed_files.append(f) return self._parsed_files @@ -188,7 +192,7 @@ def populate_metadata(_aggr): self._parsed_aggregations = [] for file in self._map.describes.files: if is_aggregation(str(file)): - self._parsed_aggregations.append(Aggregation(file.path, self._hs_session, self._checksums)) + self._parsed_aggregations.append(Aggregation(unquote(file.path), self._hs_session, self._checksums)) # load metadata for all aggregations (metadata is needed to create any typed aggregation) with ThreadPoolExecutor() as executor: From aa27d89ee5d18b014a09bfb7449867f01f0e8ce8 Mon Sep 17 00:00:00 2001 From: sblack-usu Date: Thu, 16 Oct 2025 09:38:36 -0600 Subject: [PATCH 5/5] increment version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a3868da..357f46d 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='hsclient', - version='1.1.6', + version='1.1.7', packages=find_packages(include=['hsclient', 'hsclient.*'], exclude=("tests",)), install_requires=[