[Zope3-dev] Make AbsoluteURL produce quoted urls
Stuart Bishop
stuart at stuartbishop.net
Mon May 31 19:53:01 EDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 31/05/2004, at 10:59 PM, Bjorn Tillenius wrote:
> On Mon, May 31, 2004 at 08:48:57AM -0400, Stephan Richter wrote:
>> On Saturday 29 May 2004 14:03, Bjorn Tillenius wrote:
>>> The only use case I have for AbsoluteURL is that I want to create
>>> urls to embed into HTML pages. Therefore, I would like to make it
>>> unicode capable and make it quote the url before it gets returned.
>>> Right now it can only handle ascii names, which is really bad since
>>> we allow names to be unicode.
>>>
>>> Any objections?
>>
>> Another bug that I think you have every right of fixing. :-)
>> Basically, you
>> are saying that AbsoluteURL should return unicode instead of ASCII
>> strings,
>> right? If so, go ahead and make the necessary changes.
>
> No, it should still return ASCII strings. It should encode the name to
> utf-8 and the quote it (thus producing urls containing %xx:s).
> Actually,
> now I'm sure that's the right thing to do, I will fix it tomorrow.
Shouldn't these URL's only be quoted if they are put in a
src or href attribute? Only being able to output Unicode URL's
as encoded ASCII rather defeats the purpose of them.
<a tal:attributes="python:urlquote(context.absolute_url())"
tal:contents="context/absolute_url" />
Actually, I would have thought they would not need to be encoded
anywhere, as the browser takes care of it. I know this is the case
for Unicode domain names with the major browsers (see
http://images.stuartbishop.net/idna.html for an example,
although it is using an obscure Unicode character that is
not present in many fonts so may look a little wonky if you
aren't on a Mac. Should still work though.).
Also, on the subject of quoting URL's, do you think Unicode
domain names in a URL should be encoded using domain.encode('idna')
or using %xx notation? I suspect IDNA. If absoluteurl returns a
Unicode string, there will need to be a mechanism provided to
convert it to ASCII, as it will be non trivial (since the URL will
need to be split apart and the different components encoded
separately). I've got a similar conversion tool available
at http://www.stuartbishop.net/Software/EmailAddress which
converts Unicode email addresses to ASCII.
- --
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQFAu8VgAfqZj7rGN0oRAqj/AJ488L3a6EKC34Gl8qT37ekde0mMzQCeI4zT
JWJtL6HJzcrcVRMgrUoBuoQ=
=Sp2s
-----END PGP SIGNATURE-----
More information about the Zope3-dev
mailing list