summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/utils/text.py12
-rw-r--r--tests/regressiontests/templates/filters.py1
2 files changed, 7 insertions, 6 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index fe46e26b52..37599c15be 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -157,12 +157,12 @@ recapitalize = allow_lazy(recapitalize)
def phone2numeric(phone):
"Converts a phone number with letters into its numeric equivalent."
- letters = re.compile(r'[A-PR-Y]', re.I)
- char2number = lambda m: {'a': '2', 'c': '2', 'b': '2', 'e': '3',
- 'd': '3', 'g': '4', 'f': '3', 'i': '4', 'h': '4', 'k': '5',
- 'j': '5', 'm': '6', 'l': '5', 'o': '6', 'n': '6', 'p': '7',
- 's': '7', 'r': '7', 'u': '8', 't': '8', 'w': '9', 'v': '8',
- 'y': '9', 'x': '9'}.get(m.group(0).lower())
+ letters = re.compile(r'[A-Z]', re.I)
+ char2number = lambda m: {'a': '2', 'b': '2', 'c': '2', 'd': '3', 'e': '3',
+ 'f': '3', 'g': '4', 'h': '4', 'i': '4', 'j': '5', 'k': '5', 'l': '5',
+ 'm': '6', 'n': '6', 'o': '6', 'p': '7', 'q': '7', 'r': '7', 's': '7',
+ 't': '8', 'u': '8', 'v': '8', 'w': '9', 'x': '9', 'y': '9', 'z': '9',
+ }.get(m.group(0).lower())
return letters.sub(char2number, phone)
phone2numeric = allow_lazy(phone2numeric)
diff --git a/tests/regressiontests/templates/filters.py b/tests/regressiontests/templates/filters.py
index 88266e107b..d2e8e7473b 100644
--- a/tests/regressiontests/templates/filters.py
+++ b/tests/regressiontests/templates/filters.py
@@ -257,6 +257,7 @@ def get_filter_tests():
'filter-phone2numeric01': ('{{ a|phone2numeric }} {{ b|phone2numeric }}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") }, "&lt;1-800-2255-63&gt; <1-800-2255-63>"),
'filter-phone2numeric02': ('{% autoescape off %}{{ a|phone2numeric }} {{ b|phone2numeric }}{% endautoescape %}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") }, "<1-800-2255-63> <1-800-2255-63>"),
+ 'filter-phone2numeric03': ('{{ a|phone2numeric }}', {"a": "How razorback-jumping frogs can level six piqued gymnasts!"}, "469 729672225-5867464 37647 226 53835 749 747833 49662787!"),
# Ensure iriencode keeps safe strings:
'filter-iriencode01': ('{{ url|iriencode }}', {'url': '?test=1&me=2'}, '?test=1&amp;me=2'),