Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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
Russell Keith-Magee authored February 13, 2010
12  django/utils/text.py
@@ -157,12 +157,12 @@ def recapitalize(text):
157 157
 
158 158
 def phone2numeric(phone):
159 159
     "Converts a phone number with letters into its numeric equivalent."
160  
-    letters = re.compile(r'[A-PR-Y]', re.I)
161  
-    char2number = lambda m: {'a': '2', 'c': '2', 'b': '2', 'e': '3',
162  
-         'd': '3', 'g': '4', 'f': '3', 'i': '4', 'h': '4', 'k': '5',
163  
-         'j': '5', 'm': '6', 'l': '5', 'o': '6', 'n': '6', 'p': '7',
164  
-         's': '7', 'r': '7', 'u': '8', 't': '8', 'w': '9', 'v': '8',
165  
-         'y': '9', 'x': '9'}.get(m.group(0).lower())
  160
+    letters = re.compile(r'[A-Z]', re.I)
  161
+    char2number = lambda m: {'a': '2', 'b': '2', 'c': '2', 'd': '3', 'e': '3',
  162
+         'f': '3', 'g': '4', 'h': '4', 'i': '4', 'j': '5', 'k': '5', 'l': '5',
  163
+         'm': '6', 'n': '6', 'o': '6', 'p': '7', 'q': '7', 'r': '7', 's': '7',
  164
+         't': '8', 'u': '8', 'v': '8', 'w': '9', 'x': '9', 'y': '9', 'z': '9',
  165
+        }.get(m.group(0).lower())
166 166
     return letters.sub(char2number, phone)
167 167
 phone2numeric = allow_lazy(phone2numeric)
168 168
 
1  tests/regressiontests/templates/filters.py
@@ -257,6 +257,7 @@ def get_filter_tests():
257 257
 
258 258
         '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>"),
259 259
         '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>"),
  260
+        'filter-phone2numeric03': ('{{ a|phone2numeric }}', {"a": "How razorback-jumping frogs can level six piqued gymnasts!"}, "469 729672225-5867464 37647 226 53835 749 747833 49662787!"),
260 261
 
261 262
         # Ensure iriencode keeps safe strings:
262 263
         'filter-iriencode01': ('{{ url|iriencode }}', {'url': '?test=1&me=2'}, '?test=1&amp;me=2'),

0 notes on commit f30a4b3

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