Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #10681 -- Work around (by ignoring) invalid ETag headers.

This is a hack to work around problems in the Real World. Apparently, Opera
9.64 has been observed sending malformed headers. We now compromise our high
principles and simply ignore such bad behaviour.

Patch from Ivan Sagalaev.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 8d42902 commit d2a8bc5b40bdceb57d2e23e75ea81ba495e6bbb5 @malcolmt malcolmt committed
10 django/views/decorators/
@@ -75,7 +75,15 @@ def inner(request, *args, **kwargs):
if if_none_match or if_match:
# There can be more than one ETag in the request, so we
# consider the list of values.
- etags = parse_etags(if_none_match or if_match)
+ try:
+ etags = parse_etags(if_none_match or if_match)
+ except ValueError:
+ # In case of invalid etag ignore all ETag headers.
+ # Apparently Opera sends invalidly quoted headers at times
+ # (we should be returning a 400 response, but that's a
+ # little extreme) -- this is Django bug #10681.
+ if_none_match = None
+ if_match = None
# Compute values (if any) for the requested resource.
if etag_func:
5 tests/regressiontests/conditional_processing/
@@ -112,6 +112,11 @@ def testSingleCondition6(self):
response = self.client.get('/condition/last_modified2/')
self.assertFullResponse(response, check_etag=False)
+ def testInvalidETag(self):
+ self.client.defaults['HTTP_IF_NONE_MATCH'] = r'"\"'
+ response = self.client.get('/condition/etag/')
+ self.assertFullResponse(response, check_last_modified=False)
class ETagProcesing(TestCase):
def testParsing(self):

0 comments on commit d2a8bc5

Please sign in to comment.
Something went wrong with that request. Please try again.