Add consistent query string ordering for get_gravatar_url_for_email().

Review Request #10926 — Created Feb. 28, 2020 and submitted

Information

Djblets
release-2.0.x

Reviewers

get_gravatar_url_for_email() has to build a query string to pass to
the Gravatar services, based on provided arguments and project settings.
This is accomplished by constructing a QueryDict, passing in any and
all query string arguments we need, and then encoding it onto the end of
a URL.

The problem with this is that QueryDict encodes in dictionary
iteration order, which is not consistent across Python versions. There's
no way to sort to this. This makes it very hard to test payloads
containing a Gravatar URL in any sane way.

This change ditches QueryDict and just assembles our own ordered list
of query string key/value pairs, which we then pass to Python's own
urlencode(). This ensures that we always have a consistent order to
test with.

Djblets unit tests pass on all supported versions of Python.

Verified this fixed a unit test on Review Board when running Python 3.5.

Summary ID
Add consistent query string ordering for get_gravatar_url_for_email().
`get_gravatar_url_for_email()` has to build a query string to pass to the Gravatar services, based on provided arguments and project settings. This is accomplished by constructing a `QueryDict`, passing in any and all query string arguments we need, and then encoding it onto the end of a URL. The problem with this is that `QueryDict` encodes in dictionary iteration order, which is not consistent across Python versions. There's no way to sort to this. This makes it very hard to test payloads containing a Gravatar URL in any sane way. This change ditches `QueryDict` and just assembles our own ordered list of query string key/value pairs, which we then pass to Python's own `urlencode()`. This ensures that we always have a consistent order to test with.
45c7ee5c089c7a4e4db11851210468d2aa0068f9
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (10d10f0)