[Zope-dev] redirect burps on unicode URLs

Adam GROSZER agroszer at gmail.com
Mon Mar 1 10:59:21 EST 2010


Hello,

Thinking about the problem and this itself the following comes to my
mind. I guess we're using most of the redirect with absoluteURL().
And what does absoluteURL do? It converts unicode object names to a
URL. Seemingly in a simple way. We feed then this URL to redirect().
The edge case that happened with loginform is when the URL does not
come from absoluteURL.

My assumption is that doing the same in redirect as absoluteURL does
should be OK. (unless Tres find this out of the line with the RFC)

Excerpts from the source:

class AbsoluteURL(BrowserView):
    implements(IAbsoluteURL)

    def __unicode__(self):
        return urllib.unquote(self.__str__()).decode('utf-8')
    ...
    def __str__(self):
    ...
        name = getattr(context, '__name__', None)
    ...
        if name:
            url += '/' + urllib.quote(name.encode('utf-8'), _safe)

        return url

Monday, March 1, 2010, 3:09:33 PM, you wrote:

CT> Hi,

CT> On 03/01/2010 02:28 PM, Martin Aspeli wrote:
>>
>> I'm with Wichert here.
>> 
>> In most places, we tend to carry around unicode strings internally, and 
>> only encode on the boundaries, e.g. when the URL is "rendered". I don't 
>> see why redirect() can't have a sensible and predictable policy for 
>> unicode strings, making life easier for everyone.
>> 
>> If we think that non-ASCII URLs are illegal, then maybe we should 
>> validate for that and throw an error. However, I don't think that's the 
>> case (anymore?). In that case, passing a unicode object to the function 
>> seems entirely consistent with other places, e.g. when we pass unicode 
>> to the page template engine or return unicode from a view, which the 
>> publisher then encodes before it's pushed down to the client.

CT> I opened a question in another part of the thread, but haven't gotten an
CT> answer yet. In my understanding, a Unicode string is not able to
CT> represent the structural properties of a URL in http scheme properly,
CT> thus encoding back to ASCII is not possible.

CT> Can someone confirm or disprove this?

CT> Christian



-- 
Best regards,
 Adam GROSZER                            mailto:agroszer at gmail.com
--
Quote of the day:
Death is God's way of telling you not to be such a wise guy.



More information about the Zope-Dev mailing list