#16705: r13746 makes invalid assumption that QUERY_STRING exists
------------------------------------+---------------------------------
Reporter: raylu | Owner: aaugustin
Type: Bug | Status: new
Milestone: | Component: Generic views
Version: SVN | Severity: Release blocker
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------+---------------------------------
Changes (by aaugustin):
* needs_better_patch: 1 => 0
* easy: 1 => 0
Comment:
I had to refactor the test client a bit to write tests for this issue. I
modified the default `environ` dictionary used by
`django.test.client.RequestFactory` to contain exactly the variables
required by the WSGI spec (plus `HTTP_COOKIE` because we want to support
coookies here). The test suite still passes :)
This change is slightly backwards incompatible. If third-party code uses
Django's `RequestFactory` or `Client` for testing, and contains bugs
similar to this one (ie. rely on a variable whose presence isn't
guaranteed), its tests may fail after this change. I think this minor
incompatibility is acceptable in the context of a bug fix. We could even
argue it's a good thing to reveal unnoticed bugs.
I made two other small changes:
- `CommonMiddleware` used `if request.GET:` to test if there is a query
string, and then accessed `request.META['QUERY_STRING']`. I replaced the
check with: `if request.META.get('QUERY_STRING', ''):` to make it obvious
that it's safe to access `request.META['QUERY_STRING']` at the next line.
''This changes very subtly the behavior of "append slash" and "prepend
www" redirects. Previously, invalid query strings (like `'&'`) wouldn't be
passed on. I can't say if it was intentional. Now they are. It's really an
edge case and I think it's worth making this code more explicit. If you
disagree, just don't commit this part.''
- I stumbled upon an unrelated typo in the generic_views tests and fixed
it.
--
Ticket URL: <https://code.djangoproject.com/ticket/16705#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.