Commit f3dc37b
authored
fix:cleanFilename #606
* cleanFilename: make badchars regex less strict
cleanFilename was unnecessarily strict, also removing the legal
characters '+[]
Also, " appeared twice in the regex. And it was missing checks for
control characters.
Finally, /\ should be counted among the illegal characters, not as
whitespace.
See
https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/os/FileUtils.java;l=972?q=isValidFatFilenameChar
* cleanFilename: make whitespace regex configurable
As requested in #606, make it possible to choose how to "clean"
whitespace. Potential options:
- w => '_'
- encodeURIComponent
- w => w (i.e. do nothing -- whitespace isn't forbidden)
Also, simplify the regex -- \s already contains \t and \n, see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes1 parent cc6b82d commit f3dc37b
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
0 commit comments