Closed hisanion closed 4 weeks ago
I have solved the problem manually. To do so, you need to make two changes.
./filebin2/static/js/filebin2.js
In uploadFile function, change
filename = file.name.replace(/[^A-Za-z0-9-=,.]/g, "_");
to
filename = filename.replace(/[<>:"/\\|?*]/g, "_");
If you want to set any other limits to the filename, just change those regex expression.
You may need to encode the filename to use non-English characters for the URL.
So, I changed the line
xhr.setRequestHeader("Filename", filename);
to
xhr.setRequestHeader("Filename", "=?UTF-8?B?" + btoa(encodeURIComponent(filename)) + "?=");
./filebin2/dbl/file.go After that, there is one more filename validation check at db input.
Change
var invalidFilename = regexp.MustCompile("[^A-Za-z0-9-_=+,.]")
to
var invalidFilename = regexp.MustCompile("[<>:"/\\\\|?*]")
just like before.
This variable is used in
func (d *FileDao) ValidateInput(file *ds.File)
file.Filename = invalidFilename.ReplaceAllString(file.Filename, "_")
Hope this helps.
It is a reasonable request and it is possible that we'll see support for non-English characters in file names in the future. With the current version of filebin there are no good reasons for the strict filter. Earlier it was for security reasons, but these don't really apply the same way as before.
@hand32 Thank you for contributing. I'll see if I have a proper look at this one day. Feel free to submit a PR if you want to.
This took a bit of time, but there is a PR to address this now. It is not yet merged as I'd like a few more eyes on the changes before proceeding.
@hand32 Thank you for the suggested changes. In my PR I decided to move away from the regex and use the built-in utf8 validation in Go instead. I'd appreciate it if you're able to review the PR before I merge it.
Support for non-english characters has been merged and deployed now.
Hello,
I noticed that filebin.net does not support non-English characters in file names. When attempting to upload a file with a file name containing non-English characters, the website replaces those characters with underscores. This is a problem for me, as I sometimes need to upload files with file names in different languages.
For example, I tried to upload a file named "使用手冊.pdf", which is a user manual in Traditional Chinese. However, the website replaced the non-English characters with underscores and renamed the file to "____.pdf".
It's important for me to be able to upload files with file names in different languages. Will support for non-English characters in file names be added in the future?
Thanks in advanced.