summaryrefslogtreecommitdiff
path: root/django/utils/encoding.py
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2010-01-03 18:06:27 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2010-01-03 18:06:27 +0000
commita5fc65b46e524725f73a24405b8d2f38afedc3d4 (patch)
tree97307a7b3247150b64b23804e4586218f358e76a /django/utils/encoding.py
parent0aa12da0003fda573d30b7b0d05c08192d80c264 (diff)
Fixed #12445 -- Added ' (single quote), @ (at sign), and ~ (tilde) to safe characters in `iri_to_uri` function.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12066 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/encoding.py')
-rw-r--r--django/utils/encoding.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 335f1a1551..66e6ebdd76 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -131,12 +131,21 @@ def iri_to_uri(iri):
Returns an ASCII string containing the encoded result.
"""
- # The list of safe characters here is constructed from the printable ASCII
- # characters that are not explicitly excluded by the list at the end of
- # section 3.1 of RFC 3987.
+ # The list of safe characters here is constructed from the "reserved" and
+ # "unreserved" characters specified in sections 2.2 and 2.3 of RFC 3986:
+ # reserved = gen-delims / sub-delims
+ # gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
+ # sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
+ # / "*" / "+" / "," / ";" / "="
+ # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
+ # Of the unreserved characters, urllib.quote already considers all but
+ # the ~ safe.
+ # The % character is also added to the list of safe characters here, as the
+ # end of section 3.1 of RFC 3987 specifically mentions that % must not be
+ # converted.
if iri is None:
return iri
- return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?*')
+ return urllib.quote(smart_str(iri), safe="/#%[]=:;$&()+,!?*@'~")
# The encoding of the default system locale but falls back to the