Project

General

Profile

Actions

Defect #1243

closed

Uploading of attachment with Non-ascii filename fails when host on windows

Added by Chaoqun Zou almost 16 years ago. Updated almost 16 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Attachments
Target version:
-
Start date:
2008-05-15
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

When redmine is hosted on windows, if the uploaded attachement's file-name is Non-ascii(eg. Chinese, Japanese..), there will be an exception of invalid-argument and the uploading will fail.
The attachemented picture shows the error page.

I have found what caused this error(from the ruby way, second edition):

There are other OS issues relating to character conversion. Suppose that the operating system on which Ruby is running is set to a non-UTF-8 locale, or Ruby doesn't use UTF-8 to communicate with the OS (as is the case with the Win32 package). Then there are additional complications.
For example, Windows supports Unicode filenames and uses Unicode internally. But Ruby at the present time communicates with Windows through the legacy code page. In the case of English and most other western European editions, this is code page 1252 (or WINDOWS-1252).
You can still use UTF-8 inside your application, but you'll need to convert to the legacy code page to specify filenames. This can be done using iconv, but it's important to remember that the legacy code page can describe only a small subset of the characters available in Unicode.
In addition, this means that Ruby on Windows cannot, at present, open existing files whose names cannot be described in the legacy code page. This restriction does not apply to Mac OS X, Linux, or other systems using UTF-8 locales.

And, If modify the attachment.rb like the following, I can resolve my problem when host redmine on a Chinese version Windows server.
I am wondering that if there exist an common way to resolve this problem for the windows users?
I think if I can determine the host os is windows(easy) and the filename is Non-ascii(difficult?), then I can do some converting work like the following.

Index: attachment.rb
--- attachment.rb Base (BASE)
+++ attachment.rb Locally Modified (Based On LOCAL)
@ -75,7 +75,8 @

  1. Returns file's location on disk
    def diskfile
    - "#{@storage_path}/#{self.disk_filename}"
    + filename = "#{
    @storage_path}/#{self.disk_filename}"
    + Iconv.new("gbk", "utf-8").iconv(filename)
    end

Files

cn_file_err.JPG (76.7 KB) cn_file_err.JPG Chaoqun Zou, 2008-05-15 17:02

Related issues

Is duplicate of Redmine - Defect #1089: attachement's name maybe invalid.Closed2008-04-23

Actions
Actions #1

Updated by Jean-Philippe Lang almost 16 years ago

  • Status changed from New to Closed

Fixed in r1433. Filename will be hashed if needed.

Actions

Also available in: Atom PDF