Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use http query parameters in filename #24

Merged
merged 2 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.1
current_version = 0.4.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
author = 'nevermined-sdk-py contributors'

# The full version, including alpha/beta/rc tags
release = '0.4.1'
release = '0.4.2'
# The short X.Y version
release_parts = release.split('.') # a list
version = release_parts[0] + '.' + release_parts[1]
Expand Down
2 changes: 1 addition & 1 deletion nevermined_sdk_py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.4.1'
__version__ = '0.4.2'
from .config import (
Config
)
Expand Down
2 changes: 1 addition & 1 deletion nevermined_sdk_py/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def get_ecdsa_public_key(config):
@staticmethod
def _get_file_name(response):
try:
return re.match(r'attachment;filename=(.+)',
return re.match(r'attachment;filename=(.+?)($|\?)',
response.headers.get('content-disposition'))[1]
except Exception as e:
logger.warning(f'It was not possible to get the file name. {e}')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/keyko-io/nevermined-sdk-py',
version='0.4.1',
version='0.4.2',
zip_safe=False,
)
16 changes: 16 additions & 0 deletions tests/gateway/test_gateway.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
from nevermined_sdk_py import ConfigProvider
from nevermined_sdk_py.gateway.gateway import Gateway
from requests import Response

config = ConfigProvider.get_config()


def test_get_rsa_key():
assert Gateway.get_rsa_public_key(config)


def test_get_file_name():
response = Response()

response.headers = {"content-disposition": "attachment;filename=test.txt"}
print(response.headers.get("content-disposition"))
file_name = Gateway._get_file_name(response)
assert file_name == "test.txt"

response.headers = {
"content-disposition": "attachment;filename=test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256"
}
file_name = Gateway._get_file_name(response)
assert file_name == "test.txt"