From 85959dcf9d757d7f2f4e7acae9438b9a40985112 Mon Sep 17 00:00:00 2001
From: Dheerendra Rathor <dheeru.rathor14@gmail.com>
Date: Wed, 28 Oct 2015 12:24:57 +0530
Subject: [PATCH] Fixed #25620 Changed '*' to '+' in domain name regex

Initially domain name regex had '*' which was allowing '.' to pass
the regex and making invalid URLs as valid (http://example...com).
Now atleast one unicode character will be required after '.' in
domain name regex
---
 django/core/validators.py         | 2 +-
 tests/validators/invalid_urls.txt | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/django/core/validators.py b/django/core/validators.py
index ee026f5..69cc76f 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -84,7 +84,7 @@ class URLValidator(RegexValidator):
 
     # Host patterns
     hostname_re = r'[a-z' + ul + r'0-9](?:[a-z' + ul + r'0-9-]*[a-z' + ul + r'0-9])?'
-    domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]*(?<!-))*'
+    domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]+(?<!-))*'
     tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?'
     host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)'
 
diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
index a3393d7..12a1226 100644
--- a/tests/validators/invalid_urls.txt
+++ b/tests/validators/invalid_urls.txt
@@ -49,3 +49,4 @@ http://.www.foo.bar./
 http://[::1:2::3]:8080/
 http://[]
 http://[]:8080
+http://example..com/
-- 
1.9.1

