Bug 31066

Summary: [GTK] opening local files on win32
Product: WebKit Reporter: Josip <josip>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Major CC: eric, fridrich.strba, josip, mrobinson, zecke
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
change setting of mime types on win os
eric: review-
change setting of mime types on win os (2. try)
none
Patch for this issue with tests gustavo: review+

Josip
Reported 2009-11-03 09:44:03 PST
Created attachment 42391 [details] change setting of mime types on win os Hi! Due to mime-share-info misconfiguration or missing dependencies on user side local files ("file://") can not be opened. As g_file_info_get_content_type() returns just file extension (like ".html") and win32 use those to determine mime type can we use g_content_type_get_mime_type() on them like in attachment.
Attachments
change setting of mime types on win os (558 bytes, patch)
2009-11-03 09:44 PST, Josip
eric: review-
change setting of mime types on win os (2. try) (1.20 KB, patch)
2009-11-04 12:43 PST, Josip
no flags
Patch for this issue with tests (5.50 KB, patch)
2010-09-07 18:05 PDT, Martin Robinson
gustavo: review+
Eric Seidel (no email)
Comment 1 2009-11-03 13:01:01 PST
Comment on attachment 42391 [details] change setting of mime types on win os This patch needs a ChangeLog. Also I don't think josip is a reviewer. See http://webkit.org/coding/commit-review-policy.html
Eric Seidel (no email)
Comment 2 2009-11-03 13:01:39 PST
See http://webkit.org/coding/contributing.html for instructions on how to post patches to webkit.
Josip
Comment 3 2009-11-04 12:43:04 PST
Created attachment 42514 [details] change setting of mime types on win os (2. try) Sorry for confusion! Added ChangeLog to patch (should read instructions more carefully). Misunderstood "add" for "+" but why i was allowed to do that in first place, shouldn't that be restricted based on user status. (Tool-tips for all options shows: Request for patch review)
Martin Robinson
Comment 4 2009-11-05 08:20:29 PST
I wonder if this might be the right thing to do for all platforms and not just for PLATFORM_WIN32.
Holger Freyther
Comment 5 2009-11-07 00:13:07 PST
(In reply to comment #0) > Created an attachment (id=42391) [details] > change setting of mime types on win os > > Hi! > Due to mime-share-info misconfiguration or missing dependencies on user side > local files ("file://") can not be opened. > As g_file_info_get_content_type() returns just file extension (like ".html") > and win32 use those to determine mime type can we use > g_content_type_get_mime_type() on them like in attachment. Why don't just fix the misconfiguration? I don't think this workaround is clever...
Josip
Comment 6 2009-11-07 02:23:20 PST
> > Why don't just fix the misconfiguration? I don't think this workaround is > clever... How to do that? I make mime-shared-info for win32, make environment variables like in linux and run update-mime-database but "content_type" is still just the file suffix (".html" not "text/html"). What do i do wrong? Did i miss some dependencies? Is this working for someone and how?
Holger Freyther
Comment 7 2009-11-07 02:49:50 PST
I have little idea from Windows32. In general I would like to see a test case for Glib/Gio and then an explanation of why it is failing on windows. Once we have that we can decide on a fix?
Josip
Comment 8 2009-11-07 08:15:20 PST
(In reply to comment #7) > I have little idea from Windows32. In general I would like to see a test case > for Glib/Gio and then an explanation of why it is failing on windows. Once we > have that we can decide on a fix? Not that i know anything about that but maybe valid explanation is on: http://library.gnome.org/devel/gio/stable/gio-GContentType.html which says: """ A content type is a platform specific string that defines the type of a file. On unix it is a mime type, on win32 it is an extension string like ".doc", ".txt" or a percieved string like "audio". Such strings can be looked up in the registry at HKEY_CLASSES_ROOT. """ Not sure what you mean by test case, is that something for "run-webkit-tests" or this would do: /////////////////////////////////////////////////////////////////////////////// /* gio_test */ #include <gio/gio.h> #include <stdio.h> int main(int argc, const char * argv[]) { g_type_init (); GFile * file = g_file_new_for_commandline_arg (argv[1]); GError *error = 0; GFileInfo* info = g_file_query_info (file, "standard::*", G_FILE_QUERY_INFO_NONE , NULL, NULL); printf("If GFile is '%s' then from GFileInfo content type is '%s'\n", g_file_get_basename(file), g_file_info_get_content_type(info)); printf("and from MIME is '%s', ", g_content_type_from_mime_type(g_file_info_get_content_type(info))); printf("even if his mime type is '%s'\n", g_content_type_get_mime_type(g_file_info_get_content_type(info))); return (0); } /////////////////////////////////////////////////////////////////////////////// $ ./gio_test ~/wtest.html If GFile is 'wtest.html' then from GFileInfo content type is 'text/html' and from MIME is 'text/html', even if his mime type is 'text/html' $ wine ./gio_test.exe ~/wtest.html If GFile is 'wtest.html' then from GFileInfo content type is '.html' and from MIME is '(null)', even if his mime type is 'text/html'
Martin Robinson
Comment 9 2009-11-07 08:19:54 PST
There are some tests in WebKit/gtk/tests. You could probably make one much like the code you just posted. In light of your previous comment, I'd say this fix does not need to be protected by a PLATFORM #ifdefs. It should apply equally to all platforms.
Jan Alonzo
Comment 10 2009-11-09 01:38:23 PST
Comment on attachment 42514 [details] change setting of mime types on win os (2. try) > + #if PLATFORM(WIN_OS) > + response.setMimeType(g_content_type_get_mime_type(g_file_info_get_content_type(info))); > + #else > response.setMimeType(g_file_info_get_content_type(info)); > + #endif Were there any issues running the tests in WebKit/gtk/tests? You should be able to add a test for this issue in one of the unit tests in that directory. Also, there shouldn't be a space before #if/#else/#endif. r- because of the extra spaces. It would be nice if we have test for this too.
Josip
Comment 11 2009-11-15 06:24:42 PST
All 15 tests from WebKit/gtk/tests passed OK ############################################################################### C:\WebKitGTK-1.1.16\bin\unittests>FOR %f IN (*.exe) DO %f C:\WebKitGTK-1.1.16\bin\unittests>testatk.exe /webkit/atk/get_text_at_offset: OK C:\WebKitGTK-1.1.16\bin\unittests>testdownload.exe /webkit/download/create: OK /webkit/download/perform: OK C:\WebKitGTK-1.1.16\bin\unittests>testhittestresult.exe /webkit/hittestresult/document: OK /webkit/hittestresult/image: OK /webkit/hittestresult/editable: OK /webkit/hittestresult/link: OK C:\WebKitGTK-1.1.16\bin\unittests>testhttpbackend.exe /webkit/soupmessage/lifetime: OK C:\WebKitGTK-1.1.16\bin\unittests>testkeyevents.exe /webkit/keyevent/textfield: OK /webkit/keyevent/buttons: OK /webkit/keyevent/link: OK C:\WebKitGTK-1.1.16\bin\unittests>testloading.exe /webkit/loading/status: OK /webkit/loading/error: OK /webkit/loading/cancelled: OK C:\WebKitGTK-1.1.16\bin\unittests>testnetworkrequest.exe /webkit/networkrequest/createdestroy: OK /webkit/networkrequest/properties: OK C:\WebKitGTK-1.1.16\bin\unittests>testnetworkresponse.exe /webkit/networkresponse/createdestroy: OK /webkit/networkresponse/properties: OK C:\WebKitGTK-1.1.16\bin\unittests>testwebbackforwardlist.exe /webkit/webbackforwardlist/add_item: OK /webkit/webbackforwardlist/list_order: OK /webkit/webhistoryitem/lifetime: OK C:\WebKitGTK-1.1.16\bin\unittests>testwebdatasource.exe /webkit/webdatasource/get_initial_request: OK /webkit/webdatasource/api: OK /webkit/webdatasource/unreachable_uri: OK C:\WebKitGTK-1.1.16\bin\unittests>testwebframe.exe /webkit/webview/create_destroy: OK /webkit/webframe/lifetime: OK /webkit/webview/printing: OK C:\WebKitGTK-1.1.16\bin\unittests>testwebhistoryitem.exe /webkit/webhistoryitem/get_data: OK /webkit/webhistoryitem/alternate_title: OK C:\WebKitGTK-1.1.16\bin\unittests>testwebresource.exe /webkit/webresource/get_url: OK /webkit/webresource/get_mime_type: OK /webkit/webresource/get_text_encoding_name: OK /webkit/webresource/get_frame_name: OK /webkit/webresource/get_data: OK /webkit/webresource/loading: OK /webkit/webresource/sub_resource_loading: OK C:\WebKitGTK-1.1.16\bin\unittests>testwebsettings.exe /webkit/websettings/user_agent: OK C:\WebKitGTK-1.1.16\bin\unittests>testwindow.exe /webkit/window/scrollbar_policy: OK ############################################################################### same result with both patched and unpatched version as "testwebresorce" dont use "file:" but "http:". Is that what i should expand for testing local files. As for spaces, it took me long to figure out what you meen :) Should check some surrounding code first.
Martin Robinson
Comment 12 2010-09-07 18:05:44 PDT
Created attachment 66813 [details] Patch for this issue with tests
Gustavo Noronha (kov)
Comment 13 2010-09-24 11:19:46 PDT
Comment on attachment 66813 [details] Patch for this issue with tests Very good, looks like we can uncomment those ogg tests now, too as we discussed on IRC =).
Martin Robinson
Comment 14 2010-09-24 16:37:12 PDT
Note You need to log in before you can comment on or make changes to this bug.