Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How bad is idea of letting users to upload and store files with national characters in the filename?

Our CMS accepts files with national characters in their names and stores them on the server without a problem. But how bad is such approach in perspective? For example is it possible to store files with filenames in Hebrew, or Arabic or in any other language with non-latin alphabet? Is there a standard established way to handle these?

like image 403
jayarjo Avatar asked Dec 02 '10 08:12

jayarjo


People also ask

Why is it a bad idea to have spaces in file names used in a website?

Spaces are not supported by all operating systems or by command line applications. A space in a filename can cause errors when loading a file or when transferring files between computers. Common replacements for spaces in a filenames are dashes (-) or underscores (_).

Why are special characters not allowed in filenames?

There is no requirement to delimit the filename in any way (e.g. surround it with quotes or spaces), so encountering such a special char would cause incorrect parsing (i.e is the special char part of the filename or an operator?).

What characters are allowed in filenames?

Supported characters for a file name are letters, numbers, spaces, and ( ) _ - , . *Please note file names should be limited to 100 characters. Characters that are NOT supported include, but are not limited to: @ $ % & \ / : * ? " ' < > | ~ ` # ^ + = { } [ ] ; !


1 Answers

A standard way would be to generate unique names yourself and store the original file name somewhere else. Typically, even if your underlying OS and file system allow arbitrary Unicode characters in the file name, you don't want users to decide about file names on your server. Doing so may impose certain risks and lead to problems, e.g. caused by too long names or file system collisions. Examples of sites that do that would be Facebook, flickr and many other.

For generating the unique file name Guid values would be a good choice.

like image 200
Dirk Vollmar Avatar answered Sep 26 '22 01:09

Dirk Vollmar