Paperclip - How to control which characters are escaped/changed to an underscore in an uploaded filename?

paperclip, ruby-on-rails

Solution

After some digging I found this undocumented option for has_attached_file:

:restricted_characters

The default value of this option seems to be this:

:restricted_characters => /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,

The last one is a space. Remove it and you're good.

Problem

In a recent paperclip gem upgrade I noticed that the uploaded filenames are being modified and some characters are being changed to an underscore. I don't not like the fact that it changes spaces to underscores. What's wrong with a space in a file name? The 90's are long over..

Original source