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

fix: support duplicated query param values #617

Merged
merged 2 commits into from
Sep 20, 2022
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
7 changes: 4 additions & 3 deletions tests/unit/test_request_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ def test_compute_signature_duplicate_multi_dict(self):
params = MultiDict([
("Sid", "CA123"),
("SidAccount", "AC123"),
("Digits", "5678"),
("Digits", "1234"),
("Digits", "5678"), # Ensure keys are sorted.
("Digits", "1234"), # Ensure values are sorted.
("Digits", "1234"), # Ensure duplicates are removed.
])
signature = self.validator.compute_signature(self.uri, params)
assert signature == expected

def test_compute_signature_duplicate_query_dict(self):
expected = self.duplicate_expected
params = QueryDict('Sid=CA123&SidAccount=AC123&Digits=5678&Digits=1234', encoding='utf-8')
params = QueryDict('Sid=CA123&SidAccount=AC123&Digits=5678&Digits=1234&Digits=1234', encoding='utf-8')
signature = self.validator.compute_signature(self.uri, params)
assert signature == expected

Expand Down
2 changes: 1 addition & 1 deletion twilio/request_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def compute_signature(self, uri, params):
for param_name in sorted(set(params)):
values = self.get_values(params, param_name)

for value in sorted(values):
for value in sorted(set(values)):
s += param_name + value

# compute signature and compare signatures
Expand Down