whipper-team / whipper

Python CD-DA ripper preferring accuracy over speed
GNU General Public License v3.0
1.14k stars 90 forks source link

Catalog Number within Square Brackets creates re.error #547

Closed BioBox closed 3 years ago

BioBox commented 3 years ago

Bug Description

I'm attempting to rip a cd in where I have the catalog number as part of it's output directory.

Steps to Reproduce

  1. Insert a cd with a catalog number that python's glob module would interpret as a character range.
  2. Set the disc_template so that it contains the string [%%C]
  3. Perform the rip. One example of a cd that fulfills the above requirement is found here

Stack trace

Traceback (most recent call last):
  File "/usr/bin/whipper", line 33, in <module>
    sys.exit(load_entry_point('whipper==0.10.0', 'console_scripts', 'whipper')())
  File "/usr/lib/python3.9/site-packages/whipper/command/main.py", line 56, in main
    ret = cmd.do()
  File "/usr/lib/python3.9/site-packages/whipper/command/basecommand.py", line 141, in do
    return self.cmd.do()
  File "/usr/lib/python3.9/site-packages/whipper/command/basecommand.py", line 141, in do
    return self.cmd.do()
  File "/usr/lib/python3.9/site-packages/whipper/command/cd.py", line 203, in do
    ret = self.doCommand()
  File "/usr/lib/python3.9/site-packages/whipper/command/cd.py", line 381, in doCommand
    logs = glob.glob(os.path.join(dirname, '*.log'))
  File "/usr/lib/python3.9/glob.py", line 22, in glob
    return list(iglob(pathname, recursive=recursive))
  File "/usr/lib/python3.9/glob.py", line 74, in _iglob
    for dirname in dirs:
  File "/usr/lib/python3.9/glob.py", line 75, in _iglob
    for name in glob_in_dir(dirname, basename, dironly):
  File "/usr/lib/python3.9/glob.py", line 86, in _glob1
    return fnmatch.filter(names, pattern)
  File "/usr/lib/python3.9/fnmatch.py", line 58, in filter
    match = _compile_pattern(pat)
  File "/usr/lib/python3.9/fnmatch.py", line 52, in _compile_pattern
    return re.compile(res).match
  File "/usr/lib/python3.9/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.9/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.9/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.9/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.9/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.9/sre_parse.py", line 834, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib/python3.9/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.9/sre_parse.py", line 598, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range A-7 at position 71

Why is this happening?

It's obvious when you look at the stack trace. whipper uses the glob module to generate the log file(s). When this happens it sees "[A-713914]" as a glob pattern which of course is invalid.

Enviornment

OS and Versions

Drive information

[drive:HL-DT-ST%3ADVD%2B-RW%20GU90N%20%20%20%3AA1C3] vendor = HL-DT-ST model = DVD+-RW GU90N release = A1C3 defeats_cache = True read_offset = 102

github-actions[bot] commented 3 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing instructions.