summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-17 01:19:03 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-17 01:19:03 +0000
commit5b4e2637f916c2831684e1933cfd2d2f01cb6d9e (patch)
tree9db240c373ddc2458a2e20bf381a32f393781904
parente4cd34cbeeb66e7d6f9b5665d10d4faadba1eedd (diff)
unicode: Fixed urlencode filter to handle IRI portions and map them to URI
portions correctly. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/defaultfilters.py2
-rw-r--r--tests/regressiontests/defaultfilters/tests.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 1a1c5b96fe..e85780ab79 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -170,7 +170,7 @@ upper = stringfilter(upper)
def urlencode(value):
"Escapes a value for use in a URL"
import urllib
- return smart_unicode(urllib.quote(value))
+ return smart_unicode(urllib.quote(smart_str(value)))
urlencode = stringfilter(urlencode)
def urlize(value):
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index f1af7b7bfb..2e6c565eb7 100644
--- a/tests/regressiontests/defaultfilters/tests.py
+++ b/tests/regressiontests/defaultfilters/tests.py
@@ -115,7 +115,8 @@ u'\xcb'
u'jack%20%26%20jill'
>>> urlencode(1)
u'1'
-
+>>> urlencode(u'S\xf8r-Tr\xf8ndelag')
+u'S%C3%B8r-Tr%C3%B8ndelag'
>>> urlizetrunc(u'http://short.com/', 20)
u'<a href="http://short.com/" rel="nofollow">http://short.com/</a>'