diff options
| author | Tim Graham <timograham@gmail.com> | 2013-08-12 12:41:39 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-08-12 12:41:39 -0400 |
| commit | 71b5617c24bb997db294480f07611233069e3359 (patch) | |
| tree | ec1ed7cdba18a6a3d3e011ad5ccc28b97eef786c /django | |
| parent | 6bdb3b1135d1bd7b2dc24131b9d26ac19ebdba67 (diff) | |
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.
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/base.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/template/base.py b/django/template/base.py index ed4196012a..382b85aefd 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -6,7 +6,7 @@ from importlib import import_module 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.itercompat import is_iterable from django.utils.text import (smart_split, unescape_string_literal, @@ -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 |
