mirror of
https://github.com/django/django.git
synced 2025-10-30 09:06:13 +00:00
[1.6.x] Fixed #17778 -- Prevented class attributes on context from resolving as template variables.
Thanks KyleMac for the report, regebro for the patch, and Aymeric for the test.
Backport of 71b5617c24 from master.
This commit is contained in:
@@ -5,7 +5,7 @@ from functools import partial
|
||||
from inspect import getargspec
|
||||
|
||||
from django.conf import settings
|
||||
from django.template.context import (Context, RequestContext,
|
||||
from django.template.context import (BaseContext, Context, RequestContext,
|
||||
ContextPopException)
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.itercompat import is_iterable
|
||||
@@ -765,6 +765,9 @@ class Variable(object):
|
||||
current = current[bit]
|
||||
except (TypeError, AttributeError, KeyError, ValueError):
|
||||
try: # attribute lookup
|
||||
# Don't return class attributes if the class is the context:
|
||||
if isinstance(current, BaseContext) and getattr(type(current), bit):
|
||||
raise AttributeError
|
||||
current = getattr(current, bit)
|
||||
except (TypeError, AttributeError):
|
||||
try: # list-index lookup
|
||||
|
||||
Reference in New Issue
Block a user