Defect #11568

Uploaded file name gets mangled when it contains a +

Added by Olivier Mehani over 5 years ago. Updated almost 3 years ago.

Status:ConfirmedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Attachments
Target version:Candidate for next minor release
Resolution: Affected version:

Description

When uploading a file which names contains a "+", that character gets silently replaced by a space. I suppose this has to do with the parsing of the QUERY_STRING, but it is annoying there as the + should remain verbatim in the name of the file offered for download through Redmine.

Steps to reproduce:
  1. Create a file with a '+' in its name (say, "a+b");
  2. Upload it in the files section of a Redmine project
  3. The file appears as "a b", and the download link leads to ".../a%20b"

While the file downloads correctly, it is inconvenient to have one's file renamed without control.

a+b - This file was initially named 'a+b' (4 Bytes) Olivier Mehani, 2012-08-02 06:54

History

#1 Updated by Olivier Mehani over 5 years ago

  • File a+b added

#2 Updated by Olivier Mehani over 5 years ago

Right, my experiment shows that I am not up to date. Is this a known bug that has already been addressed? I couldn't find it in the issues.

#3 Updated by Etienne Massip over 5 years ago

  • Category set to Attachments
  • Status changed from New to Confirmed
  • Target version set to Candidate for next minor release

Redmine.org is not running the latest version but demo is.

And indeed, it happens with trunk.

#4 Updated by Jean-Philippe Lang over 5 years ago

Seems to be a Rails issue. The + is already replaced with a space in the original_filename found in attachment params:

"attachments"=>{"1"=>{"file"=>#<ActionDispatch::Http::UploadedFile:0x4c11fa8 @original_filename="test plus.txt",
 @content_type="text/plain", @headers="Content-Disposition: form-data; name=\"attachments[1][file]\"; 
filename=\"test+plus.txt\"\r\nContent-Type: text/plain\r\n", @tempfile=#<File:xxx/RackMultipart20120814-2236-ogyxbd>>, "description"=>""}}

#5 Updated by Jean-Baptiste Barth over 4 years ago

It works now fine on 2.3.1 and trunk, but confirmed broken on 2.2.4 and 2.1.6.

Relevant log on a fresh install:

redmine-2.2.4/log/development.log:  Parameters: [...] "attachments"=>{"1"=>{"file"=>#<ActionDispatch::Http::UploadedFile:0x007fcb8a55e5d0
@original_filename="a b.txt", @content_type="text/plain", @headers="Content-Disposition: form-data; name=\"attachments[1][file]\";
filename=\"a+b.txt\"\r\nContent-Type: text/plain\r\n", @tempfile=#<File:/var/folders/2d/ym9f6qbd61x6_xxc51f17wq40000gn/T/
RackMultipart20130505-96276-1v561qz>>, "description"=>""}}, [...]

redmine-2.3.1/log/development.log:  Parameters: [...] "attachments"=>{"1"=>{"filename"=>"a+b.txt", "description"=>"",
"token"=>"1.0d599f0ec05c3bda8c3b8a68c32a1b47"}} [...]

The fix is probably related to r10977 ?

Now that it works I think we need to add some tests to ensure it won't break again.

#6 Updated by Go MAEDA almost 3 years ago

Olivier Mehani wrote:

Steps to reproduce:
  1. Create a file with a '+' in its name (say, "a+b");
  2. Upload it in the files section of a Redmine project
  3. The file appears as "a b", and the download link leads to ".../a%20b"

While the file downloads correctly, it is inconvenient to have one's file renamed without control.

No problem on Redmine 3.0.0.
It seems that we can close this issue.

Also available in: Atom PDF