[patch] urlencode to use optional safe argument for urllib.quote
|Reported by:||Kaaya||Owned by:||nobody|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I know this issue got set as wontfix before but the previous solution was not backwards compatible and this one is.
def urlencode(value, safe='/'): "Escapes a value for use in a URL" import urllib return urllib.quote(value, safe)
urlencode will work exactly as is does now but can *optionally* set which characters won't be escaped. The / character is the default for urllib.quote http://docs.python.org/lib/module-urllib.html
Test case for this is when you have a url stored in the db e.g. "http://djangoproject.com/" if you do a var|urlencode on that you get back 'http%3Adjangoproject.com/' which will cause the browser to show http://example.com/http://djangoproject.com/ which is not what you want but if you can use var|urlencode:":/" you'll get the link working properly.
Change History (2)
comment:1 Changed 7 years ago by Simon G. <dev@…>
- Has patch set
- Keywords urlencode added
- Summary changed from urlencode to use optional safe argument for urllib.quote to [patch] urlencode to use optional safe argument for urllib.quote
- Triage Stage changed from Unreviewed to Design decision needed