Bug 61721

Summary: upload filename can not contain characters other than latin1
Product: [Applications] konqueror Reporter: LiuCougar <liucougar>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Makes the file upload use the page encoding instead

Description LiuCougar 2003-07-27 12:42:51 UTC
Version:            (using KDE KDE 3.1.2)
Installed from:    Gentoo Packages
Compiler:          gcc 3.2.3 gcc version 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r1, propolice)
OS:          Linux

I am Chinese, and I just find that after uploaded a file whose name contains Chinese characters, on the server running PHP 4.3.2 + apache 1.3.27 all the Chinese characters in the file name changes to "?".

I again use Mozilla to upload the same file to the same server, and the result is just correct.

I find the problem is caused by the conversion to ascii, in file khtml/html/html_formimpl.cpp in package kdelibs, line 267

hstr += ("; filename=\"" + onlyfilename + "\"").ascii();

I modify it to

hstr += ("; filename=\"" + onlyfilename + "\"").local8Bit();

and uploading works fine.

Hope you can correct this next version.

Thanks.
Comment 1 Thiago Macieira 2003-07-27 13:30:16 UTC
Created attachment 2081 [details]
Makes the file upload use the page encoding instead

It should probably use the page's encoding, like other form elements do.

Can you please test the attached patch?
Comment 2 LiuCougar 2003-07-27 16:34:17 UTC
It works fine, thanks. 
Comment 3 Maksim Orlovich 2003-07-27 17:31:56 UTC
Hold on for a bit, I don't think Thiago commited this yet :-) 
 
Comment 4 Thiago Macieira 2003-07-27 22:42:26 UTC
Subject: KDE_3_1_BRANCH: kdelibs/khtml/html

CVS commit by thiago: 

Fixing in branch.
CCMAIL:61721@bugs.kde.org


  M +1 -1      html_formimpl.cpp   1.300.2.11


--- kdelibs/khtml/html/html_formimpl.cpp  #1.300.2.10:1.300.2.11
@@ -268,5 +268,5 @@ QByteArray HTMLFormElementImpl::formData
                         QString onlyfilename = path.mid(path.findRev('/')+1);
 
-                        hstr += ("; filename=\"" + onlyfilename + "\"").ascii();
+                        hstr += fixUpfromUnicode(codec, "; filename=\"" + onlyfilename + "\"");
                         if(!static_cast<HTMLInputElementImpl*>(current)->value().isEmpty())
                         {


Comment 5 Thiago Macieira 2003-07-27 22:43:42 UTC
Subject: kdelibs/khtml/html

CVS commit by thiago: 

And fixing in HEAD.

Thanks for reporting.
CCMAIL:61721-done@bugs.kde.org 


  M +2 -2      html_formimpl.cpp   1.328


--- kdelibs/khtml/html/html_formimpl.cpp  #1.327:1.328
@@ -269,5 +269,5 @@ QByteArray HTMLFormElementImpl::formData
                         QString onlyfilename = path.mid(path.findRev('/')+1);
 
-                        hstr += ("; filename=\"" + onlyfilename + "\"").ascii();
+                        hstr += fixUpfromUnicode(codec, "; filename=\"" + onlyfilename + "\"");
                         if(!static_cast<HTMLInputElementImpl*>(current)->value().isEmpty()) {
                             KMimeType::Ptr ptr = KMimeType::findByURL(KURL(path));