Ticket #25620: 0001-Fixed-25620-Changed-to-in-domain-name-regex.patch

File 0001-Fixed-25620-Changed-to-in-domain-name-regex.patch, 1.4 KB (added by Dheerendra Rathor, 8 years ago)
  • django/core/validators.py

    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 b class URLValidator(RegexValidator):  
    8484
    8585    # Host patterns
    8686    hostname_re = r'[a-z' + ul + r'0-9](?:[a-z' + ul + r'0-9-]*[a-z' + ul + r'0-9])?'
    87     domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]*(?<!-))*'
     87    domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]+(?<!-))*'
    8888    tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?'
    8989    host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)'
    9090
  • tests/validators/invalid_urls.txt

    diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
    index a3393d7..12a1226 100644
    a b http://.www.foo.bar./  
    4949http://[::1:2::3]:8080/
    5050http://[]
    5151http://[]:8080
     52http://example..com/
Back to Top