Re: [PATCH] Fix heavily broken relative URI resolution



On Fri, 2006-04-21 at 13:41 +0200, Christian Neumair wrote:
> Am Donnerstag, den 20.04.2006, 16:03 +0200 schrieb Alexander Larsson:
> > On Sun, 2006-03-19 at 17:06 +0100, Christian Neumair wrote:
> > > Am Sonntag, den 19.03.2006, 13:09 +0100 schrieb Christian Neumair:
> > > > The attached patch implements the relative URI resolution as suggested
> > > > by RFC 2396 and RFC 3986. The old algorithm was quite hosed, for
> > > > instance when the relative reference had too many ".." components, which
> > > > overwrote the authority component of an URI.
> > > > "ftp://server/foo";, "../../../" would be resolved to some garbage like
> > > > "ftp:///";.
> > > > 
> > > > After applying this patch, test-uri passes all URI relative resolution
> > > > tests in RFC 3986.
> > 
> > I'm a bit worried by this patch. It rewrites some pretty core parts of
> > gnome-vfs, and it mentions RFCs a lot.
> 
> Yes, because resolve_relative claims to conform to an RFC, where it
> doesn't, and is used way too often, for instance for resolving a
> relative path name or file name. It's simply a helper that does text
> manipulation according to an RFC, and the docs produce the impression
> that it can be used for things it wasn't meant to be used for. For
> example, _gnome_vfs_uri_resolve_all_symlinks_uri should use
> gnome_vfs_resolve_symlink instead of resolve_relative. The ftp method
> also makes use of it.

The reference to the RFC was added long after the code was initially
written and its behaviour defined by the initial code. In fact it was
added by you. Maybe instead of changing the behaviour that apps might
rely on since ages we should remove the RFC reference from the docs.
gnome-vfs uris are subtly different than "web-uris" in several ways, so
maybe that is better.

> > Does this fix any important issues in practice, or is it more of a
> > cleanness fix?
> 
> It doesn't fix nor further break any issues, because I'm not aware of
> any client application using the _resolve_relative helper correctly,
> i.e. for what it was meant to be used. People who rely on standard
> compliant software will still find it helpful, though - although these
> persons may not be interested in GnomeVFSURIs at all, so we should
> provide a text-only variant (gnome_vfs_resolve_relative).

Nautilus uses the similar function gnome_vfs_uri_resolve_relative
correctly in nautilus_file_get_symbolic_link_target_uri. There is no
reason _gnome_vfs_uri_resolve_all_symlinks_uri couldn't correctly use
resolve_relative. It just needs to escape the symlink value before
passing it in. (In fact, I'm commiting a patch to do this right now.)

The fact is that gnome-vfs URIs are really not identical to web-uris,
and gnome-vfs isn't a library for implementing web-browsers. Its
unfortunate that they use the same name for so similar objects, but its
far to late to do anything about that. 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a time-tossed albino paranormal investigator living undercover at 
Ringling Bros. Circus. She's a chain-smoking paranoid widow who inherited a 
spooky stately manor from her late maiden aunt. They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]