diff --git a/django/utils/html.py b/django/utils/html.py
index c4be281..ba5f753 100644
a
|
b
|
def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
168 | 168 | url = smart_urlquote('http://%s' % middle) |
169 | 169 | elif not ':' in middle and simple_email_re.match(middle): |
170 | 170 | local, domain = middle.rsplit('@', 1) |
171 | | domain = domain.encode('idna') |
| 171 | try: |
| 172 | domain = domain.encode('idna') |
| 173 | except UnicodeError: |
| 174 | continue |
172 | 175 | url = 'mailto:%s@%s' % (local, domain) |
173 | 176 | nofollow_attr = '' |
174 | 177 | |
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index 94e8c43..36f8f58 100644
a
|
b
|
class DefaultFiltersTests(TestCase):
|
288 | 288 | self.assertEqual(urlize('usa.gov'), |
289 | 289 | u'<a href="http://usa.gov" rel="nofollow">usa.gov</a>') |
290 | 290 | |
| 291 | # Check urlize don't crash on invalid email with dot-starting domain - see #17592 |
| 292 | self.assertEqual(urlize('email@.stream.ru'), |
| 293 | u'email@.stream.ru') |
| 294 | |
291 | 295 | def test_wordcount(self): |
292 | 296 | self.assertEqual(wordcount(''), 0) |
293 | 297 | self.assertEqual(wordcount(u'oneword'), 1) |