mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Fixed #5557: URLs are now properly escaped in the cache_page decorator. Thanks, eriks.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6435 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2dd882885b
commit
964f0c16ad
1
AUTHORS
1
AUTHORS
@ -114,6 +114,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Enrico <rico.bl@gmail.com>
|
Enrico <rico.bl@gmail.com>
|
||||||
A. Murat Eren <meren@pardus.org.tr>
|
A. Murat Eren <meren@pardus.org.tr>
|
||||||
Ludvig Ericson <ludvig.ericson@gmail.com>
|
Ludvig Ericson <ludvig.ericson@gmail.com>
|
||||||
|
eriks@win.tue.nl
|
||||||
Dirk Eschler <dirk.eschler@gmx.net>
|
Dirk Eschler <dirk.eschler@gmx.net>
|
||||||
Marc Fargas <telenieko@telenieko.com>
|
Marc Fargas <telenieko@telenieko.com>
|
||||||
Szilveszter Farkas <szilveszter.farkas@gmail.com>
|
Szilveszter Farkas <szilveszter.farkas@gmail.com>
|
||||||
|
@ -23,7 +23,7 @@ import time
|
|||||||
from email.Utils import formatdate
|
from email.Utils import formatdate
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
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*')
|
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)
|
value = request.META.get(header, None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
ctx.update(value)
|
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):
|
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:
|
if key_prefix is None:
|
||||||
key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
|
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)
|
headerlist = cache.get(cache_key, None)
|
||||||
if headerlist is not None:
|
if headerlist is not None:
|
||||||
return _generate_cache_key(request, headerlist, key_prefix)
|
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
|
key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
|
||||||
if cache_timeout is None:
|
if cache_timeout is None:
|
||||||
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
|
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'):
|
if response.has_header('Vary'):
|
||||||
headerlist = ['HTTP_'+header.upper().replace('-', '_') for header in vary_delim_re.split(response['Vary'])]
|
headerlist = ['HTTP_'+header.upper().replace('-', '_') for header in vary_delim_re.split(response['Vary'])]
|
||||||
cache.set(cache_key, headerlist, cache_timeout)
|
cache.set(cache_key, headerlist, cache_timeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user