-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Directories.sanitizeFilname] various fixes (#4060)
Most Unix file systems typically allow filenames of up to 255 bytes. However, the actual number of characters allowed can vary due to the representation of Unicode characters. Therefore length checks must be done in bytes, not unicode. Remove re.split(r"/|\\", filename) because we obviously can't split on character that have already been removed by the blacklist. Remember this function is supposed to process a prospective filename, not a path. Add a max length argument to command lengths other than 255, e.g. when we are going to append ascii to the filename. Simplify a lot of overcomplicated code. Add comments to make easy to understand. [Directories.getRecordingFilename] also here filename length was being calulated in unicode, not bytes. Use sanitizeFilename to clean up recording filename rather than having code duplication. Get rid of this bug: path += "_%03d" % i >>> path = "abc.def" >>> for i in range(5): ... path += "_%03d" % i ... print(path) ... abc.def_000 abc.def_000_001 abc.def_000_001_002 abc.def_000_001_002_003 abc.def_000_001_002_003_004 >>>
- Loading branch information
Showing
1 changed file
with
27 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters