1

When uploading files to a server. Should the file name be sanitized? i.e. avoiding non-ASCII characters like é or &?

Or should we allow these files to be saved as is?

PS. In Rails 3, I can't remember the method. It changes non-ascii chars to underscores and etc. Someone remind me pls. It's not sanitize. Its a different method.

Christian Fazzini
  • 19,613
  • 21
  • 110
  • 215

1 Answers1

1

Be aware that you sanitize /, \ and \0 if sent from maliciuos user agents. If your filesystem fully supports Unicode, I would save them as they were sent by agent.

My preferred solution: Use a unique id as filename and store real filename in an additional file or database. So your application gets portable for systems not supporting Unicode

UllaDieTrulla
  • 573
  • 1
  • 5
  • 18