Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #12613 -- Added Q and Z to the list of characters suppo…

…rted by the phone2numeric filter. Thanks to gabrielhurley for the report and patch.

Backport of r12425 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12427 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f30a4b368cd6a03dfbbfd2145d06f747664ece86 1 parent d751f2c
@freakboy3742 freakboy3742 authored
View
12 django/utils/text.py
@@ -157,12 +157,12 @@ def recapitalize(text):
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)
View
1  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'),

0 comments on commit f30a4b3

Please sign in to comment.
Something went wrong with that request. Please try again.