[Zope-CMF] Re: [CMF-checkins] link object / CMF 1.3b2

Florent Guillaume fg@nuxeo.com
01 Jul 2002 11:50:59 +0200


Ok, I reread RFC1808 and you're right that I don't handle relative URLs
correctly. I'll re-change that.

On Sun, 2002-06-30 at 13:34, Yuppie wrote:
> > Brainfart from my part, thanks. I corrected that.
> > Could you please review the testcases (test_fixupMissingScheme,
> > test_trailingSlash) for correctness ?
> 
> Looks ok to me. Besides I don't like the way you handle relative URLs.
> 
> +        elif remote_url[:1] == '/':
> +            # Starts with a slash, site-relative URL,
> +            # no way to completely absolutize it.
> +            url = urlparse.urlunparse(tokens)
> +        else:
> +            # Starts with a host without http:// qualification,
> +            # add it correctly because urlparse didn't do it.
> +            tokens = urlparse.urlparse('http://'+remote_url)
> +            url = urlparse.urlunparse(tokens)
> 
> I don't understand why you distinguish these two cases. In both cases 
> you change a relative URL to an invalid absolute URL.

Because Links are to be used with absolute URLs in general, I wanted to
make "google.com/language_tool" be understood correctly, as the
syntax-equivalent "somerelativedir/index.html" wasn't likely to be
entered by the user.

You're right that I should not add http: in front of real relative URLs.
The "else" case is supposed to deal with my google example above.

> >>The code I proposed on tracker issue 507 was just a bugfix. If you want 
> >>to improve URL testing and fixup, I can have a closer look at it and 
> >>send you a proposal.
> > 
> > 
> > Well, your code silently discarded what the user typed in some cases.
> > That's not acceptable.
> 
> Yes. But I don't think changing silently a valid relativ URL like 
> /huh/zoinx.html into http:/huh/zoinx.html is the better solution.
> 
> I think the right way would be to leave remote_url unchanged and return 
> an error message if the URL can't be fixed. But that would be a bigger 
> change.

Yes, the code is not designed to refuse or return error on user entry.

> >>And PLEASE don't forget to update version.txt files before releasing 1.3b2.
> > 
> > Good idea, I'll do that later so Tres won't forget it :)

Actually Tres is here now so I'll let him do that.


Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com