Ticket #16501: slug_unicode_16501.diff

File slug_unicode_16501.diff, 2.3 KB (added by Piotr Banaszkiewicz, 13 years ago)
  • django/core/validators.py

    diff --git a/django/core/validators.py b/django/core/validators.py
    index 95224e9..20d08f4 100644
    a b email_re = re.compile(  
    164164    r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE)  # literal form, ipv4 address (SMTP 4.1.3)
    165165validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid')
    166166
    167 slug_re = re.compile(r'^[-\w]+$')
    168 validate_slug = RegexValidator(slug_re, _(u"Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."), 'invalid')
     167slug_re = re.compile(r'^[-\w]+$', re.U)
     168validate_slug = RegexValidator(slug_re, _(u"Enter a valid 'slug' consisting of unicode letters, numbers, underscores or hyphens."), 'invalid')
    169169
    170170ipv4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$')
    171171validate_ipv4_address = RegexValidator(ipv4_re, _(u'Enter a valid IPv4 address.'), 'invalid')
  • docs/ref/validators.txt

    diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt
    index 0f29989..2759c7d 100644
    a b to, or in lieu of custom ``field.clean()`` methods.  
    118118
    119119``validate_slug``
    120120-----------------
     121.. versionadded:: 1.4
     122
    121123.. data:: validate_slug
    122124
    123125    A :class:`RegexValidator` instance that ensures a value consists of only
    124     letters, numbers, underscores or hyphens.
     126    unicode letters, numbers, underscores or hyphens.
    125127
    126128``validate_ipv4_address``
    127129-------------------------
  • tests/modeltests/validators/tests.py

    diff --git a/tests/modeltests/validators/tests.py b/tests/modeltests/validators/tests.py
    index a1a48bf..dc6f567 100644
    a b TEST_DATA = (  
    3838    (validate_slug, 'longer-slug-still-ok', None),
    3939    (validate_slug, '--------', None),
    4040    (validate_slug, 'nohyphensoranything', None),
     41    (validate_slug, '你好', None),
    4142
    4243    (validate_slug, '', ValidationError),
    4344    (validate_slug, ' text ', ValidationError),
    4445    (validate_slug, ' ', ValidationError),
    4546    (validate_slug, 'some@mail.com', ValidationError),
    46     (validate_slug, '你好', ValidationError),
     47    (validate_slug, '你 好', ValidationError),
    4748    (validate_slug, '\n', ValidationError),
    4849
    4950    (validate_ipv4_address, '1.1.1.1', None),
Back to Top