mnamer icon indicating copy to clipboard operation
mnamer copied to clipboard

Strings are not sanitized in directory paths

Open emturnbull opened this issue 5 years ago • 2 comments

Strings are not sanitized in the directory path. For example, if you wanted to store TV shows in {series}{series} - S{season}E{episode} format, a colon in {series} will be removed in the filename but not in the directory structure. I tracked this down to str_sanitize being called on the filename but not on the dir_tail in the destination() method in target.py

My clumsy hack of a fix was simply to split the dir_tail into individual directory names and call str_sanitize on them, e.g.

        sep = "\\" if "\\" in dir_tail else "/"
        dir_tail_pieces = dir_tail.split(sep)
        cleaned_pieces = []
        for piece in dir_tail_pieces:
            cleaned_pieces.append(str_sanitize(piece))
        dir_tail = sep.join(cleaned_pieces)

which I added to target.py on line 110 (after the call to sanitize the filename).

emturnbull avatar Oct 22 '20 12:10 emturnbull

This seems similar to #100

lozbrown avatar Oct 27 '20 16:10 lozbrown

This occurs when --episode-format has a path in addition to the filename.

Resolving MR https://github.com/jkwill87/mnamer/pull/150

Resolving commit https://github.com/jkwill87/mnamer/pull/150/commits/a28f18eb8a3ebc16a29df7785c56ca57dac5a20d

WaywardWizard avatar Jun 16 '21 06:06 WaywardWizard