Ticket #2276: validators.py.2.diff

File validators.py.2.diff, 1.0 KB (added by nkeric, 9 years ago)

decode utf-8 encoded string for doing re search

  • django/core/validators.py

     
    2727integer_re = re.compile(r'^-?\d+$')
    2828ip4_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}$')
    2929phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
    30 slug_re = re.compile(r'^[-\w]+$')
     30slug_re = re.compile(r'^[-\w]+$', re.UNICODE)
    3131url_re = re.compile(r'^https?://\S+$')
    3232
    3333lazy_inter = lazy(lambda a,b: str(a) % b, str)
     
    6767        raise ValidationError, gettext("This value must contain only letters, numbers, underscores, dashes or slashes.")
    6868
    6969def isSlug(field_data, all_data):
    70     if not slug_re.search(field_data):
     70    if not slug_re.search(unicode(field_data, 'utf-8')):
    7171        raise ValidationError, "This value must contain only letters, numbers, underscores or hyphens."
    7272
    7373def isLowerCase(field_data, all_data):
Back to Top