Bug 15221

Summary: Make the FileSystemChooserGdk implementation properly convert the WebCore::String presentation
Product: WebKit Reporter: Holger Freyther <zecke>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal Keywords: Gtk
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
Properly convert the name of the file
aroben: review-
Convert properly mrowe: review+

Description Holger Freyther 2007-09-15 07:20:05 PDT
Currently the code assumes that the filesystem/system is using UTF-8. This assumption does not always hold true and there are the g_filename_convert_{from,to}_utf8 function to convert from the UTF-8 representation to the filesystem locale.
Also implement proper NULL checking for the filechooser get_filename method.
Comment 1 Holger Freyther 2007-09-15 07:21:37 PDT
Created attachment 16297 [details]
Properly convert the name of the file

This should implement the NULL-checking and should properly convert from WebCore::String -> UTF-8 -> filesystem and from filesystem -> UTF-8 -> WebCore::String.
Comment 2 Adam Roben (:aroben) 2007-09-16 13:16:06 PDT
Comment on attachment 16297 [details]
Properly convert the name of the file

+                gchar* basename = g_filename_to_utf8(basenameSystem, -1, 0, 0, 0);
+                g_free(basenameSystem);
+
+                if (basename) {
+                    string = String::fromUTF8(basename);
+                    g_free(basename);
+                }

This sequence should be factored out into a static helper function instead of repeating it twice in this file. Otherwise looks good.
Comment 3 Holger Freyther 2007-09-17 04:25:27 PDT
Created attachment 16304 [details]
Convert properly

This takes the comments of Adam from this bug report and irc into account.
Comment 4 Mark Rowe (bdash) 2007-09-17 07:51:44 PDT
Comment on attachment 16304 [details]
Convert properly

I think "convertToStringByAdoptingTheFilesystemRepresentation" may be a little bit wordy.  At the least, I think "The" does not add anything.  Elsewhere we also treat "filesystem" as two words.  Perhaps "stringWithFileSystemRepresentation" would be a better name?

"filenameSystem" also feels backwards.  "systemFilename" reads better to me.

Other than these naming niggles, r=me.
Comment 5 Holger Freyther 2007-09-17 08:09:23 PDT
(In reply to comment #4)
> (From update of attachment 16304 [details] [edit])
> I think "convertToStringByAdoptingTheFilesystemRepresentation" may be a little
> bit wordy.  At the least, I think "The" does not add anything.  Elsewhere we
> also treat "filesystem" as two words.  Perhaps
> "stringWithFileSystemRepresentation" would be a better name?
> 
> "filenameSystem" also feels backwards.  "systemFilename" reads better to me.
> 
> Other than these naming niggles, r=me.
> 

Oops, I landed that without reading that part. I agree with systemFilename and will do a fixup (without going through review) but the function name is difficult as it takes ownership of the systemFilename and we wanted to have that inside the name.