From df09d854828bcff56eb72f48ff1ba8fce7e90c90 Mon Sep 17 00:00:00 2001
From: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon, 9 Jun 2014 21:24:05 +0200
Subject: [PATCH] Fixed #17552 -- Removed a hack for IE6 and earlier.

It prevented the GZipMiddleware from compressing some data types even on
more recent version of IE where the corresponding bug was fixed.

Thanks Aaron Cannon for the report and Tim Graham for the review.
---
 django/middleware/gzip.py |  8 +-------
 docs/ref/middleware.txt   |  5 -----
 docs/releases/1.8.txt     |  5 +++++
 tests/middleware/tests.py | 10 ----------
 4 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/django/middleware/gzip.py b/django/middleware/gzip.py
index e9e955d704..8548c083e3 100644
--- a/django/middleware/gzip.py
+++ b/django/middleware/gzip.py
@@ -17,17 +17,11 @@ class GZipMiddleware(object):
         if not response.streaming and len(response.content) < 200:
             return response
 
-        patch_vary_headers(response, ('Accept-Encoding',))
-
         # Avoid gzipping if we've already got a content-encoding.
         if response.has_header('Content-Encoding'):
             return response
 
-        # MSIE have issues with gzipped response of various content types.
-        if "msie" in request.META.get('HTTP_USER_AGENT', '').lower():
-            ctype = response.get('Content-Type', '').lower()
-            if not ctype.startswith("text/") or "javascript" in ctype:
-                return response
+        patch_vary_headers(response, ('Accept-Encoding',))
 
         ae = request.META.get('HTTP_ACCEPT_ENCODING', '')
         if not re_accepts_gzip.search(ae):
diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt
index d5958dfebd..7b7b76b567 100644
--- a/docs/ref/middleware.txt
+++ b/docs/ref/middleware.txt
@@ -108,11 +108,6 @@ It will NOT compress content if any of the following are true:
 * The request (the browser) hasn't sent an ``Accept-Encoding`` header
   containing ``gzip``.
 
-* The request is from Internet Explorer and the ``Content-Type`` header
-  contains ``javascript`` or starts with anything other than ``text/``.
-  We do this to avoid a bug in early versions of IE that caused decompression
-  not to be performed on certain content types.
-
 You can apply GZip compression to individual views using the
 :func:`~django.views.decorators.gzip.gzip_page()` decorator.
 
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 774d94d94d..26b9d37a88 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -273,6 +273,11 @@ Miscellaneous
 * Database connections are considered equal only if they're the same object.
   They aren't hashable any more.
 
+* :class:`~django.middleware.gzip.GZipMiddleware` used to disable compression
+  for some content types when the request is from Internet Explorer, in order
+  to work around a bug in IE6 and earlier. This behavior could affect
+  performance on IE7 and later. It was removed.
+
 * ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
 
 * ``django.contrib.gis`` dropped support for GEOS 3.1 and GDAL 1.6.
diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py
index 98420501a6..7df1d04418 100644
--- a/tests/middleware/tests.py
+++ b/tests/middleware/tests.py
@@ -613,16 +613,6 @@ class GZipMiddlewareTest(TestCase):
         self.assertEqual(r.content, self.compressible_string)
         self.assertEqual(r.get('Content-Encoding'), 'deflate')
 
-    def test_no_compress_ie_js_requests(self):
-        """
-        Tests that compression isn't performed on JavaScript requests from Internet Explorer.
-        """
-        self.req.META['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)'
-        self.resp['Content-Type'] = 'application/javascript; charset=UTF-8'
-        r = GZipMiddleware().process_response(self.req, self.resp)
-        self.assertEqual(r.content, self.compressible_string)
-        self.assertEqual(r.get('Content-Encoding'), None)
-
     def test_no_compress_uncompressible_response(self):
         """
         Tests that compression isn't performed on responses with uncompressible content.