Skip to content

Commit

Permalink
Merge remote branch 'chenba/589291-validations'
Browse files Browse the repository at this point in the history
  • Loading branch information
clouserw committed Aug 30, 2010
2 parents 75eebbd + 6d240cd commit aae8369
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/users/models.py
Expand Up @@ -68,7 +68,11 @@ class UserProfile(amo.models.ModelBase):
display_collections = models.BooleanField(default=False)
display_collections_fav = models.BooleanField(default=False)
emailhidden = models.BooleanField(default=False)
homepage = models.CharField(max_length=255, blank=True, default='')
homepage = models.URLField(max_length=255, blank=True, default='',
verify_exists=False, error_messages={
'invalid': _('This URL has an invalid format. '
'Valid URLs look like '
'http://example.com/my_page.')})
location = models.CharField(max_length=255, blank=True, default='')
notes = models.TextField(blank=True, null=True)
notifycompat = models.BooleanField(default=True)
Expand Down
7 changes: 7 additions & 0 deletions apps/users/tests/test_forms.py
Expand Up @@ -272,6 +272,13 @@ def test_invalid_username(self):
self.assertFormError(r, 'form', 'username',
'This username is invalid.')

def test_invalid_homepage(self):
data = {'homepage': 'example.com:alert(String.fromCharCode(88,83,83)'}
m = 'This URL has an invalid format. '
m += 'Valid URLs look like http://example.com/my_page.'
r = self.client.post('/en-US/firefox/users/register', data)
self.assertFormError(r, 'form', 'homepage', m)

def test_already_logged_in(self):
self.client.login(username='jbalogh@mozilla.com', password='foo')
r = self.client.get('/users/register', follow=True)
Expand Down

0 comments on commit aae8369

Please sign in to comment.