You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/12/23 10:00:24 UTC

DO NOT REPLY [Bug 25720] New: - MultipartElement.getFileName() returns wrong filename for non-English names

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25720>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25720

MultipartElement.getFileName() returns wrong filename for non-English names

           Summary: MultipartElement.getFileName() returns wrong filename
                    for non-English names
           Product: Struts
           Version: 1.1 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: File Upload
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: irith@mercury.co.il


When upload a file which has a non-English name,
the upload component can not get the correct filename.

The problem is caused by the following reason:
MultipartIterator is using MultipartBoundaryInputStream, that has the function:
private final String readLine() 
In that function there is :
line = new String(this.line, 0, this.lineLength);
This causes the byte array to be treated as if it would have been in default 
encoding.
The corrected code should include an "encoding" class parameter, that would be 
initialized in the MultipartBoundaryInptStream constructor (should be the 
encoding of the request or the MultipartElement), and than the above code of 
readLine() would be changed to :
line = new String(this.line, 0, this.lineLength, this.encoding); 


I'd like to mention that for MultipartElement.getName() and 
MultipartElement.getValue() the bug doesn't occur. this is thanks to the 
function MultipartIterator.createTextMultipartElement() that is considering the 
encoding at the line:
String value = baos.toString(encoding);
So text elements are working fine, but file elements are using the above 
readLine() method, and there we see the bug.
 
This is seriously harming Struts i18n support, we really need this fix.

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org