Reviewed by Maciej.

        - fixed 3366542 -- filename with non-ASCII name left out of Content-Disposition for <input type=file>

        * khtml/html/html_formimpl.cpp: (HTMLFormElementImpl::formData):
        Do the &-encoding thing on the filename. This is what Gecko does.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4835 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index bf6b295..564c33c 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,12 @@
+2003-08-17  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed 3366542 -- filename with non-ASCII name left out of Content-Disposition for <input type=file>
+
+        * khtml/html/html_formimpl.cpp: (HTMLFormElementImpl::formData):
+        Do the &-encoding thing on the filename. This is what Gecko does.
+
 2003-08-14  Maciej Stachowiak  <mjs@apple.com>
 
         Fixed by Darin, reviewed by me (and originally figured out by John).
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index bf6b295..564c33c 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,12 @@
+2003-08-17  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed 3366542 -- filename with non-ASCII name left out of Content-Disposition for <input type=file>
+
+        * khtml/html/html_formimpl.cpp: (HTMLFormElementImpl::formData):
+        Do the &-encoding thing on the filename. This is what Gecko does.
+
 2003-08-14  Maciej Stachowiak  <mjs@apple.com>
 
         Fixed by Darin, reviewed by me (and originally figured out by John).
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 8426b68e..8740101 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -346,7 +346,21 @@
                     {
                         QString path = static_cast<HTMLInputElementImpl*>(current)->value().string();
                         if (path.length()) fileUploads << path;
-                        QString onlyfilename = path.mid(path.findRev('/')+1);
+
+                        // Turn non-ASCII characters into &-escaped form.
+                        // This doesn't work perfectly, because it doesn't escape &, for example.
+                        // But it seems to be what Gecko does.
+                        QString onlyfilename;
+                        for (uint i = path.findRev('/') + 1; i < path.length(); ++i) {
+                            QChar c = path.at(i).unicode();
+                            if (c.unicode() >= 0x20 && c.unicode() <= 0x7F) {
+                                onlyfilename.append(&c, 1);
+                            } else {
+                                QString ampersandEscape;
+                                ampersandEscape.sprintf("&%hu;", c.unicode());
+                                onlyfilename.append(ampersandEscape);
+                            }
+                        }
 
                         // FIXME: This won't work if the filename includes a " mark,
                         // or control characters like CR or LF.