summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2015-11-11 20:10:55 +0100
committerTim Graham <timograham@gmail.com>2015-11-24 11:31:10 -0500
commit9f83fc2f66f5a0bac7c291aec55df66050bb6991 (patch)
tree45b752afc60b120d10fa409d60cee274e2176375 /django
parent581b9e504752840fd7716e44c5c30292636355a4 (diff)
[1.8.x] Fixed a settings leak possibility in the date template filter.
This is a security fix.
Diffstat (limited to 'django')
-rw-r--r--django/utils/formats.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 30ab3e03eb..767871b301 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -33,6 +33,24 @@ ISO_INPUT_FORMATS = {
}
+FORMAT_SETTINGS = frozenset([
+ 'DECIMAL_SEPARATOR',
+ 'THOUSAND_SEPARATOR',
+ 'NUMBER_GROUPING',
+ 'FIRST_DAY_OF_WEEK',
+ 'MONTH_DAY_FORMAT',
+ 'TIME_FORMAT',
+ 'DATE_FORMAT',
+ 'DATETIME_FORMAT',
+ 'SHORT_DATE_FORMAT',
+ 'SHORT_DATETIME_FORMAT',
+ 'YEAR_MONTH_FORMAT',
+ 'DATE_INPUT_FORMATS',
+ 'TIME_INPUT_FORMATS',
+ 'DATETIME_INPUT_FORMATS',
+])
+
+
def reset_format_cache():
"""Clear any cached formats.
@@ -95,6 +113,8 @@ def get_format(format_type, lang=None, use_l10n=None):
be localized (or not), overriding the value of settings.USE_L10N.
"""
format_type = force_str(format_type)
+ if format_type not in FORMAT_SETTINGS:
+ return format_type
if use_l10n or (use_l10n is None and settings.USE_L10N):
if lang is None:
lang = get_language()