Ticket #5786: auth.1.path

File auth.1.path, 2.3 KB (added by Bob Gao, 17 years ago)
Line 
1Index: django/core/validators.py
2===================================================================
3--- django/core/validators.py (revision 6913)
4+++ django/core/validators.py (working copy)
5@@ -23,6 +23,7 @@
6 _datere = r'\d{4}-\d{1,2}-\d{1,2}'
7 _timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
8 alnum_re = re.compile(r'^\w+$')
9+alnum_u_re = re.compile(r'^\w+$', re.U)
10 alnumurl_re = re.compile(r'^[-\w/]+$')
11 ansi_date_re = re.compile('^%s$' % _datere)
12 ansi_time_re = re.compile('^%s$' % _timere)
13@@ -71,6 +72,11 @@
14 if not alnum_re.search(field_data):
15 raise ValidationError, _("This value must contain only letters, numbers and underscores.")
16
17+def isAlphaNumericU(field_data, all_data):
18+ if not alnum_u_re.search(field_data):
19+ raise ValidationError, _("This value must contain only alphanumeric in the Unicode character properties database.")
20+
21+
22 def isAlphaNumericURL(field_data, all_data):
23 if not alnumurl_re.search(field_data):
24 raise ValidationError, _("This value must contain only letters, numbers, underscores, dashes or slashes.")
25Index: django/contrib/auth/tests.py
26===================================================================
27--- django/contrib/auth/tests.py (revision 6913)
28+++ django/contrib/auth/tests.py (working copy)
29@@ -35,4 +35,6 @@
30 []
31 >>> a.user_permissions.all()
32 []
33-"""
34\ No newline at end of file
35+>>> from django.core.validators import *
36+>>> isAlphaNumericU(u'abcd', '')
37+"""
38Index: django/contrib/auth/forms.py
39===================================================================
40--- django/contrib/auth/forms.py (revision 6913)
41+++ django/contrib/auth/forms.py (working copy)
42@@ -11,7 +11,7 @@
43 def __init__(self):
44 self.fields = (
45 oldforms.TextField(field_name='username', length=30, max_length=30, is_required=True,
46- validator_list=[validators.isAlphaNumeric, self.isValidUsername]),
47+ validator_list=[validators.isAlphaNumericU, self.isValidUsername]),
48 oldforms.PasswordField(field_name='password1', length=30, max_length=60, is_required=True),
49 oldforms.PasswordField(field_name='password2', length=30, max_length=60, is_required=True,
50 validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
Back to Top