The urlencode filter is actually urlquote and it doesn't accept the safe parameter
Isn't it a bit odd that the |urlencode filter is actually urllib.quote and not urllib.urlencode as the name would suggest? To make things worse it doesn't accept the safe parameter that urllib.quote takes.
I don't know whether it should deal with dictionaries or not like urllib.urlencode does, but I do believe that |urlencode should escape the same characters as urllib.urlencode.
Short story is that you can't escape a / for proper use in a query string with |urlencode because / is a default safe character in urllib.quote since / is acceptable in paths. The quickest fix would be to allow |urlencode to take the safe parameter and to have it default to an empty string.
Change History
(6)
Component: |
Serialization → Template system
|
Triage Stage: |
Unreviewed → Accepted
|
Has patch: |
set
|
Owner: |
changed from nobody to Chris Beaven
|
Status: |
new → assigned
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Patch added with tests & docs.
KyleMac: we can't make it default to an empty string, that would be backwards incompatible. But with this patch you can pass an empty string to the filter.
I'm guessing that russ' acceptance was primarily for the feature of adding the safe argument, not changing the filter name or anything.