Changeset 5283
- Timestamp:
- 05/18/07 19:17:23 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/template/defaultfilters.py
r5273 r5283 4 4 from django.conf import settings 5 5 from django.utils.translation import ugettext, ungettext 6 from django.utils.encoding import smart_unicode, smart_str 6 from django.utils.encoding import smart_unicode, smart_str, iri_to_uri 7 7 import re 8 8 import random as random_module … … 84 84 formatstr = u'%%.%df' % abs(d) 85 85 return formatstr % f 86 87 def iriencode(value): 88 "Escapes an IRI value for use in a URL" 89 return smart_unicode(iri_to_uri(value)) 90 iriencode = stringfilter(iriencode) 86 91 87 92 def linenumbers(value): … … 171 176 "Escapes a value for use in a URL" 172 177 import urllib 173 return smart_unicode(urllib.quote( smart_str(value)))178 return smart_unicode(urllib.quote(value)) 174 179 urlencode = stringfilter(urlencode) 175 180 … … 567 572 register.filter(floatformat) 568 573 register.filter(get_digit) 574 register.filter(iriencode) 569 575 register.filter(join) 570 576 register.filter(length) django/branches/unicode/django/utils/encoding.py
r5278 r5283 67 67 Returns an ASCII string containing the encoded result. 68 68 """ 69 return urllib.quote(smart_str(iri), safe='/#%[]') 69 # The list of safe characters here is constructed from the printable ASCII 70 # characters that are not explicitly excluded by the list at the end of 71 # section 3.1 of RFC 3987. 72 return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?') 70 73 django/branches/unicode/tests/regressiontests/defaultfilters/tests.py
r5273 r5283 116 116 >>> urlencode(1) 117 117 u'1' 118 >>> urlencode(u'S\xf8r-Tr\xf8ndelag')118 >>> iriencode(u'S\xf8r-Tr\xf8ndelag') 119 119 u'S%C3%B8r-Tr%C3%B8ndelag' 120 120
