From 17d3a6d8044752f482453f5906026eaf12c39e8e Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Tue, 30 Jun 2015 01:09:21 +0300 Subject: [PATCH] Fixed catastrophic backtracking in URLValidator. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks João Silva for reporting the problem and Tim Graham for finding the problematic RE and for review. This is a security fix; disclosure to follow shortly. --- django/core/validators.py | 2 +- docs/releases/1.8.3.txt | 7 +++++++ tests/validators/invalid_urls.txt | 2 ++ tests/validators/tests.py | 3 +++ tests/validators/valid_urls.txt | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/django/core/validators.py b/django/core/validators.py index d68533af9d..32158644c7 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -73,7 +73,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]+(?:[a-z' + ul + r'0-9-]*[a-z' + ul + r'0-9]+)*)*' + domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]*(?