Add consistent query string ordering for get_gravatar_url_for_email().
Review Request #10926 — Created Feb. 28, 2020 and submitted
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
The problem with this is that
QueryDictencodes 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
QueryDictand 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
Djblets unit tests pass on all supported versions of Python.
Verified this fixed a unit test on Review Board when running Python 3.5.