Opened 18 years ago
Closed 17 years ago
#2694 closed enhancement (invalid)
[patch] urlencode to use optional safe argument for urllib.quote
Reported by: | Kaaya | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | trivial | Keywords: | urlencode |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 by , 18 years ago
Has patch: | set |
---|---|
Keywords: | urlencode added |
Summary: | urlencode to use optional safe argument for urllib.quote → [patch] urlencode to use optional safe argument for urllib.quote |
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I don't really understand the use case for this. urlencoding the ":" in URIs is correct for your example.
I like the fact that this doesn't break the backwards compatibility, and does add some functionality in an easy way. However, I'm not sure how much of a problem this to warrent a check in?