Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #5557: URLs are now properly escaped in the cache_page decorato…

…r. Thanks, eriks.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6435 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 964f0c16ad3c62bcae755b9b6b025bb1b69e1231 1 parent 2dd8828
@jacobian jacobian authored
Showing with 5 additions and 4 deletions.
  1. +1 −0  AUTHORS
  2. +4 −4 django/utils/cache.py
View
1  AUTHORS
@@ -114,6 +114,7 @@ answer newbie questions, and generally made Django that much better:
Enrico <rico.bl@gmail.com>
A. Murat Eren <meren@pardus.org.tr>
Ludvig Ericson <ludvig.ericson@gmail.com>
+ eriks@win.tue.nl
Dirk Eschler <dirk.eschler@gmx.net>
Marc Fargas <telenieko@telenieko.com>
Szilveszter Farkas <szilveszter.farkas@gmail.com>
View
8 django/utils/cache.py
@@ -23,7 +23,7 @@
from email.Utils import formatdate
from django.conf import settings
from django.core.cache import cache
-from django.utils.encoding import smart_str
+from django.utils.encoding import smart_str, iri_to_uri
cc_delim_re = re.compile(r'\s*,\s*')
@@ -125,7 +125,7 @@ def _generate_cache_key(request, headerlist, key_prefix):
value = request.META.get(header, None)
if value is not None:
ctx.update(value)
- return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, request.path, ctx.hexdigest())
+ return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, iri_to_uri(request.path), ctx.hexdigest())
def get_cache_key(request, key_prefix=None):
"""
@@ -139,7 +139,7 @@ def get_cache_key(request, key_prefix=None):
"""
if key_prefix is None:
key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
- cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path)
+ cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(request.path))
headerlist = cache.get(cache_key, None)
if headerlist is not None:
return _generate_cache_key(request, headerlist, key_prefix)
@@ -163,7 +163,7 @@ def learn_cache_key(request, response, cache_timeout=None, key_prefix=None):
key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
if cache_timeout is None:
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
- cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path)
+ cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(request.path))
if response.has_header('Vary'):
headerlist = ['HTTP_'+header.upper().replace('-', '_') for header in vary_delim_re.split(response['Vary'])]
cache.set(cache_key, headerlist, cache_timeout)
Please sign in to comment.
Something went wrong with that request. Please try again.