Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

extension of illegal characters in file upload.js

Avatar

Level 2

Hi Team, 

 

I am trying to extend the fileupload.js functionality. There are few more special characters like 'à','ç' (continuous pressing of 'A'/'C' in the keyboard will popup these values). So how can I restrict those values ?

 

 

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Shetty1191 ,

 

To achieve this, we would need to overlay the fileupload.js in : /libs/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js

 

After overlaying that in apps, you would need to:

Add the values/characters which you need to restrict in the _ILLEGAL_FILENAME_CHARS variable (separate them with ,) on line103. - This is the variable which takes care of all the restricted words. 

 

I think the DamFileUpload and DamFolderUpload both use this same variable.

 

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Hi @Shetty1191 ,

 

To achieve this, we would need to overlay the fileupload.js in : /libs/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js

 

After overlaying that in apps, you would need to:

Add the values/characters which you need to restrict in the _ILLEGAL_FILENAME_CHARS variable (separate them with ,) on line103. - This is the variable which takes care of all the restricted words. 

 

I think the DamFileUpload and DamFolderUpload both use this same variable.

 

Avatar

Community Advisor

give the complete file path which u are trying to overlay ..and what u want to restrict

Avatar

Community Advisor

ILLEGAL_FILENAME_CHARS: ['*', '/', ':', '[', '\\', ']', '|', '#', '%','{','}','?', '&','à','ç'],

 

It should work ..please check

Avatar

Level 2

It is possible to give a regex pattern to it instead of adding all the characters ?

Avatar

Employee Advisor

Hi @Shetty1191 ,

Please try using the following regex, it covers almost all accented characters:

^[\u00C0-\u00FF]*$

Add this regex to ILLEGAL_FILENAME_CHARS to disallow the accented characters to be used in filename.

 

Thanks.

Avatar

Level 2

I gave '^[\u00C0-\u00FF]*$' like this but it is not working @milind_bachani .

 

Thanks.