GNOME Bugzilla – Bug 317456
GURI is unable to parse file:/// URIs
Last modified: 2006-09-11 09:24:31 UTC
Please describe the problem: GURI is not able to parse file:/// style URIs. Upon giving gnet_uri_new() a file:/// URI, NULL is being returned. Steps to reproduce: 1. Run: GURI *guri = gnet_uri_new("file:///foo/bar/wee/yahoo.file"); (or any other file:/// URI) 2. guri is NULL Actual results: The return value is NULL Expected results: A valid GURI with the initial URI string properly parsed into the GURI struct. Does this happen every time? Yes. Other information: No other information :P
Created attachment 52782 [details] [review] Proposed fix for this bug. This patch effectively fixes the bug.
There are some things I'm wondering about, like whether the file:// protocol/schema be special-cased in certain ways? For example: 1) Do we only want to allow absolute paths? If yes, we need to special-case and check for the third slash. If no, we should either return an error or prepend the current working directory to the path. With the current patch, we'd silently split up relative paths into hostname and path rest, which doesn't sound quite right. 2) What to do with fragment/etc.? Should we special-case file:// URIs and thus allow '#' and '?' characters in the path (especially the '?' might be common in song titles)? Or should we just process them as usual and split them off? I'm leaning towards special-casing file:// URIs for both 1) and 2) What do you think? Cheers -Tim
Should be fixed in CVS: 2006-09-11 Tim-Philipp Müller <tim at centricular dot net> * src/uri.c: (gnet_uri_new), (gnet_uri_get_string): * tests/uri_test.c: (main): Add support for absolute file:// URIs and add two simple test cases. Not entirely convinced about the required fix to _get_string(), but it doesn't seem to break any of the tests, so it can't be too bad even if it's not entirely correct. Fixes bug #317456. Based on patch by Milosz Derezynski <internalerror at gmail com> (Only handles absolute file URIs as it should. Escaping etc. works just like with all other URIs, so no special casing).