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.
Created attachment 126477 [details]
Implementation with GFile is also bit cleaner and simpler.
Comment on attachment 126477 [details]
Committed r107395: <http://trac.webkit.org/changeset/107395>