Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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..

like image 799
Yoni Baciu Avatar asked Dec 28 '22 01:12

Yoni Baciu


1 Answers

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.

like image 128
Yoni Baciu Avatar answered Jan 17 '23 18:01

Yoni Baciu