GNOME Bugzilla – Bug 630266
g_file_new_for_uri() doesn't like percent-encoded slashes in URLs
Last modified: 2010-09-21 16:29:37 UTC
An Empathy user reported that clicking certain links just yielded a dialog saying ‘error opening location: Operation not supported’, but not all. A bit of guesswork revealed that all the non-functional URLs contained %2F, which is the percent-encoding for a forward-slash. This is a pretty sketchy thing to find in a URL, but such URLs exist in the wild. The problem seems to be caused by: decoded->path = unescape_string (hier_part_start, hier_part_end, "/"); in _g_decode_uri: / is explicitly declared to be illegal, and so _g_decode_uri() returns NULL, so gvfs-open ultimately fails, etc. etc. leading to the user being shown a totally meaningless error message. Not really sure what the best solution would be here, besides just allowing escaped slashes in URLs. I don't really see that it would hurt anyone.
Philip Withnall did some research, and it turns out that percent-encoded slashes are perfectly legal! Gustavo Noronha did some more research, and can't find anything forbidding them in relevant RFCs, and notes that SoupURI doesn't have this check. So here's a branch that just removes the check: http://git.collabora.co.uk/?p=user/wjt/glib;a=commitdiff;h=refs/heads/laxer-uri-parsing.
Created attachment 170763 [details] [review] GFile: accept URIs containing percent-encoded / in path And here's the patch if folks want to review it here.
The problem is that GFile doesn't deal with "real" URIs, it deals with gvfs URIs, which have different (and incompatible) encoding/decoding rules. Yes, this is a mess. *** This bug has been marked as a duplicate of bug 581032 ***