From 8f9a4d3a2bc42f14bb437defd30c7315adbff22c Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Tue, 30 Jun 2015 01:09:21 +0300 Subject: [PATCH] [1.8.x] 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 f97b3d9772..cd5b16b207 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-]*(?