idlesign / deflacue

Cue Sheet driven FLAC audio splitter
https://github.com/idlesign/deflacue
BSD 3-Clause "New" or "Revised" License
35 stars 13 forks source link

Illegal characters in target paths result in crash #4

Open perepichka opened 3 years ago

perepichka commented 3 years ago

Deflacue will fail to split FLAC files when Album/Band names contain illegal characters on Windows.

In my case, the album name is titled: What I Have to Hide...

The code in the process_cue method creates an additional folder structure on top of the target path using the artist name, album name, and date. In my case, it attempts to create the following: [base_directory]\\Night of Suicide\\2006 - What I Have to Hide.... However, _create_target_path method used to create this folder uses os.makedirs, which has the brilliant behavior of silently pruning the three dots at the end, creating [base_directory]\\Night of Suicide\\2006 - What I Have to Hide instead. Subsequently, the reference to the target path is now incorrect and SoX will fail as it attempts to write to the directory with the 3 dots, which does not exist.

There exists a sanitize function in process_cue, which can be extended to remove illegal characters. Additionally/alternatively, it would be nice to have an optional flag to disable the entire prepending system and simply have deflacue output to the exact directory the user passes.

I can make a PR for either or both, let me know.

idlesign commented 3 years ago

os.makedirs, which has the brilliant behavior of silently pruning the three dots at the end

That comes from the OS layer. See https://bugs.python.org/issue22744#msg230101 - so a workaround might be to sanitize those on Windows. Pull request is welcome.