Bug 78339 - [GTK] KURL::fileSystemPath() doesn't work if uri contains #
Summary: [GTK] KURL::fileSystemPath() doesn't work if uri contains #
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2012-02-10 01:52 PST by Carlos Garcia Campos
Modified: 2012-02-10 03:51 PST (History)
3 users (show)

See Also:

Patch (1.67 KB, patch)
2012-02-10 01:56 PST, Carlos Garcia Campos
pnormand: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2012-02-10 01:52:08 PST
The problem is that  KURL::fileSystemPath() uses g_filename_from_uri() to convert the uri to a local path. g_filename_from_uri() doesn't allow uris containing #, returning NULL in that case with a G_CONVERT_ERROR_BAD_URI error. 

In WebKit2, when html has been loaded from a string with loadHTML(), all relative paths must be relative to the baseURL passed to loadHTML(). To check whether a relative path is in the same directory than the baseURL, both are converted to local path. If the relative path contains a # KURL::fileSystemPath() returns an empty String and the condition is always false, making the web process to terminate. 

The solution is using GFile instead of g_filename_from_uri(), since GFile removes the anchor from the uri when converting the uri to a local path.
Comment 1 Carlos Garcia Campos 2012-02-10 01:56:21 PST
Created attachment 126477 [details]

Implementation with GFile is also bit cleaner and simpler.
Comment 2 Philippe Normand 2012-02-10 03:42:10 PST
Comment on attachment 126477 [details]

Looks good!
Comment 3 Carlos Garcia Campos 2012-02-10 03:51:24 PST
Committed r107395: <http://trac.webkit.org/changeset/107395>