#25484: static template tag outputs invalid HTML if storage class's url() 
returns a
URI with '&' characters.
-------------------------------------+------------------------------------
     Reporter:  João Miguel Neves    |                    Owner:  alix-
         Type:  Bug                  |                   Status:  new
    Component:  contrib.staticfiles  |                  Version:  master
     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 Tim Graham):

 * status:  closed => new
 * needs_better_patch:  1 => 0
 * resolution:  fixed =>


Comment:

 As discussed on the original PR, the added `unquote()` likely isn't
 correct. Here's Florian's suggestion:

 > Given that staticfiles operates on files and in general as such has no
 concept of query params, I think it is safe to assume and expect that the
 static functions are passed filenames/paths. Filenames (or rather file
 paths) literally allow basically every character aside from a null byte
 (depending on your system). If we agree that this assumption is correct
 the following steps seem logical:
 >  - To generate a URL, we are forced to run the file through urlquote,
 since it might contain characters not suitable in this form as part of the
 URL (most notably a "?" since that would mark the start of the query
 params).
 >  - Since URL generation can add API access keys, the final URL can
 indeed contain unquoted "&" and "?", which is completely valid and should
 be allowed.
 >  - When it comes to HTML though, we still have to run it through HTML
 escape since it might contain otherwise invalid or (thanks to browser
 parsing of & in that context) ambiguous characters.




 Follow up [https://github.com/django/django/pull/7714 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/25484#comment:8>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.441b9b73cc39235ae33b16f54a331160%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to