Re: redirect burps on unicode URLs

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wichert Akkerman wrote:
> On 2/25/10 17:08 , Tres Seaver wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Adam GROSZER wrote:
>>> Hello,
>>>
>>> Looks like zope.publisher burps on unicode URL which contain non-ascii
>>> chars. This is from a KGS 3.4 application, but looking at the source
>>> it still seems to have the same problems.
>>>
>>> opinions?
>>>
>>> ...
>>>      self.request.response.redirect(url)
>>>    File "d:\home\.buildout\eggs\zope.publisher-3.4.6-py2.5.egg\zope\publisher\browser.py", line
>>> 729, in redirect
>>>      return super(BrowserResponse, self).redirect(location, status)
>>>    File "d:\home\.buildout\eggs\zope.publisher-3.4.6-py2.5.egg\zope\publisher\http.py", line 882,
>>> in redirect
>>>      self.setHeader('Location', location)
>>>    File "d:\home\.buildout\eggs\zope.publisher-3.4.6-py2.5.egg\zope\publisher\http.py", line 676,
>>> in setHeader
>>>      value = str(value)
>>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in position 71: ordinal not in
>>> range(128)
>> Two issues:
>>
>> - - Technically there is no such thing as a "unicode URL":  URLs are
>>    always ASCII, with other characters encoded[1].  IRIs and IRLs are
>>    a different thing altogether.
> 
> I see this as naming confusion. In this day and age every URL is 
> effectively an IRI, and every modern browser treats them that way. If 
> you look at http://jp.wikipedia.org/ you can see how well that works. I 
> do not see why zope.publisher should not be able to support that 
> transparently. Other systems such as Routes and repoze.bfg do.

Browseers *display* what looks like unicode to the user, but they *pass*
URL-encoded ASCII bytes to the server.  Even if that weren't so, HTTP
header values (the 'Location:' header, in this case) still have to be
ASCII, period.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuIA/QACgkQ+gerLs4ltQ72NwCgu9No4P4J5y29kiTJk124GYZ2
PhYAnjNhssCzpFgNaMmL2c3Y1wVEzeKJ
=4HgE
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.