8000 Fix double encoding of string parameters by adamantike · Pull Request #263 · python-amazon-mws/python-amazon-mws · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# The short X.Y version.
version = "0.8"
# The full version, including alpha/beta/rc tags.
release = "0.8.11"
release = "0.8.14"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion mws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

from .mws import * # noqa: F401, F403

__version__ = "0.8.11"
__version__ = "0.8.14"
2 changes: 1 addition & 1 deletion mws/future_utils/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ def clean_date(val):
"""Converts a datetime.datetime or datetime.date to ISO 8601 string.
Further passes that string through `urllib.parse.quote`.
"""
return val.isoformat()
return clean_string(val.isoformat())
2 changes: 1 addition & 1 deletion mws/mws.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def calc_md5(string):
def calc_request_description(params):
request_description = ""
for key in sorted(params):
encoded_value = quote(params[key], safe="-_.~")
encoded_value = params[key]
request_description += "&{}={}".format(key, encoded_value)
return request_description[1:] # don't include leading ampersand

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import setuptools

version = "0.8.13"
version = "0.8.14"

homepage = "http://github.com/python-amazon-mws/python-amazon-mws"
short_description = "Python library for interacting with the Amazon MWS API"
Expand Down
35 changes: 33 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mws.mws import calc_md5, calc_request_description
from mws.mws import calc_md5, calc_request_description, clean_params_dict


def test_calc_md5():
Expand All @@ -11,7 +11,7 @@ def test_calc_request_description(access_key, account_id):
"AWSAccessKeyId": access_key,
"Markets": account_id,
"SignatureVersion": "2",
"Timestamp": "2017-08-12T19:40:35Z",
"Timestamp": "2017-08-12T19%3A40%3A35Z",
"Version": "2017-01-01",
"SignatureMethod": "HmacSHA256",
}
Expand All @@ -28,3 +28,34 @@ def test_calc_request_description(access_key, account_id):
"&Timestamp=2017-08-12T19%3A40%3A35Z"
"&Version=2017-01-01"
)


def test_calc_request_description_for_cleaned_params(access_key, account_id):
params = clean_params_dict(
{
"AWSAccessKeyId": access_key,
"Markets": account_id,
"Subscription.Destination.AttributeList.member.1.Key": "sqsQueueUrl",
"Subscription.Destination.AttributeList.member.1.Value": "https://sqs.us-east-1.amazonaws.com/123456789/mws-notifications",
"SignatureVersion": "2",
"Timestamp": "2017-08-12T19:40:35Z",
"Version": "2017-01-01",
"SignatureMethod": "HmacSHA256",
}
)
request_description = calc_request_description(params)

assert not request_description.startswith("&")
assert request_description == (
"AWSAccessKeyId="
+ access_key
+ "&Markets="
+ account_id
+ "&SignatureMethod=HmacSHA256"
"&SignatureVersion=2"
"&Subscription.Destination.AttributeList.member.1.Key=sqsQueueUrl"
"&Subscription.Destination.AttributeList.member.1.Value="
"https%3A%2F%2Fsqs.us-east-1.amazonaws.com%2F123456789%2Fmws-notifications"
"&Timestamp=2017-08-12T19%3A40%3A35Z"
"&Version=2017-01-01"
)
0