#29606: Validate the type of ALLOWED_HOSTS
-------------------------------------+-------------------------------------
     Reporter:  rafis                |                    Owner:  Octavio
                                     |  Peri
         Type:  New feature          |                   Status:  assigned
    Component:  Core (System         |                  Version:  master
  checks)                            |
     Severity:  Normal               |               Resolution:
     Keywords:  allowed_hosts        |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Marius Räsener):

 ok, so here's what I came up with for the check:
 {{{
 def check_allowedhosts(ALLOWED_HOSTS):
     if isinstance(ALLOWED_HOSTS,(list,tuple)):
         return all(isinstance(element,str) for element in ALLOWED_HOSTS)
     else:
         return False
 }}}
 sadly in this case `all([])` returns True so the if else statement is
 needed I think ... but of course I'm happy to get hints for a better
 implementation.

 Besides, where would I put the check and the test?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29606#comment:14>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.8f3728da3e8cab820a00afe92410908b%40djangoproject.com.

Reply via email to