Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filename validator before saving files #15

Open
b04505009 opened this issue Dec 6, 2020 · 1 comment
Open

add filename validator before saving files #15

b04505009 opened this issue Dec 6, 2020 · 1 comment

Comments

@b04505009
Copy link

b04505009 commented Dec 6, 2020

Some characters like colon and quotation mark are not allowed to be in a file's path. I recommend to use library like pathvalidate to validate those name before creating files.

I opened a PR #16

@lantw44
Copy link
Owner

lantw44 commented Jan 31, 2022

Some characters like colon and quotation mark are not allowed to be in a file's path.

這個專案最初是在 Linux 上開發的,後來也在 FreeBSD 跑過,但沒什麼測試過 Windows。我承認我當時幾乎沒有考慮檔名可能有特殊字元的問題,因此只處理了我自己測試有遇到的兩個狀況:檔名不能有 / 和檔名過長。

I recommend to use library like pathvalidate to validate those name before creating files.

我其實比較希望盡可能保留原始檔名,也就是類似目前處理檔名過長的方式:如果可以成功開啟檔案,就使用原本的檔名;如果因檔名有特殊字元而無法開啟檔案,則將特殊字元替換成 _ 或其他安全字元再重試。不知道你覺得這樣如何?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants