Skip to content

Commit

Permalink
fix: support duplicated query param values (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
childish-sambino committed Sep 20, 2022
1 parent c9c68a0 commit b3a5deb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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

0 comments on commit b3a5deb

Please sign in to comment.