Opened 12 years ago

Closed 10 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: UI/UX:


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

Test case for this is when you have a url stored in the db e.g. "" if you do a var|urlencode on that you get back '' which will cause the browser to show 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 11 years ago by Simon G. <dev@…>

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: UnreviewedDesign decision needed

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?

comment:2 Changed 10 years ago by Jacob

Resolution: invalid
Status: newclosed

I don't really understand the use case for this. urlencoding the ":" in URIs is correct for your example.

Note: See TracTickets for help on using tickets.
Back to Top