summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-08-18 19:57:50 +0200
committerClaude Paroz <claude@2xlibre.net>2014-08-18 19:57:50 +0200
commit132d0e516e5881cb3f6445e9d84e01c9f2123254 (patch)
treea8e745a733df20374bbd355ff60ee456dc0e29a4 /django/utils
parenta3d7f58151e4a2996476d400bab0335b8d616bde (diff)
Fixed #22171 -- Improved sanitize_separators cleverness
Thanks Klaas van Schelven for the report and Tim Graham for the review.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/formats.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 521ab5c763..3441f0f420 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -221,9 +221,13 @@ def sanitize_separators(value):
parts.append(decimals)
if settings.USE_THOUSAND_SEPARATOR:
thousand_sep = get_format('THOUSAND_SEPARATOR')
- for replacement in set([
- thousand_sep, unicodedata.normalize('NFKD', thousand_sep)]):
- value = value.replace(replacement, '')
+ if thousand_sep == '.' and value.count('.') == 1 and len(value.split('.')[-1]) != 3:
+ # Special case where we suspect a dot meant decimal separator (see #22171)
+ pass
+ else:
+ for replacement in set([
+ thousand_sep, unicodedata.normalize('NFKD', thousand_sep)]):
+ value = value.replace(replacement, '')
parts.append(value)
value = '.'.join(reversed(parts))
return value