#25595: Invalid regexp in URLValidator can't handle file:// schemes
------------------------------+-----------------------------------------
     Reporter:  Marcin Nowak  |                    Owner:  Adam Zapletal
         Type:  Bug           |                   Status:  assigned
    Component:  Core (Other)  |                  Version:  1.8
     Severity:  Normal        |               Resolution:
     Keywords:                |             Triage Stage:  Accepted
    Has patch:  1             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+-----------------------------------------
Changes (by Adam Zapletal):

 * cc: Adam Zapletal (added)
 * has_patch:  0 => 1
 * owner:  nobody => Adam Zapletal
 * status:  new => assigned

Comment:

 I opened a PR adding a warning about this to the documentation. I'm happy
 to handle it in a different way if that'd be better.

 For what it's worth, if someone out there wants to validate local file
 URIs, you could start with something like this:

 {{{#!python
 @deconstructible
 class CustomURLValidator(URLValidator):
     def __init__(self, **kwargs):
         super().__init__(**kwargs)

         self.schemes.append('file')

     def __call__(self, value):
         if value.startswith('file:///'):
             value = value.replace('file:///', 'file://localhost/')

         return super().__call__(value)
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/25595#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018e21a7a23f-94bb8519-b6ba-4f36-91c5-9aa0d3e4ff37-000000%40eu-central-1.amazonses.com.

Reply via email to