Uploaded image for project: 'Picard'
  1. Picard
  2. PICARD-1374

Picard crashes while typing a regular expression in some cases

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 2.1
    • 2.0.4
    • Scripting
    • None
    • openSUSE Tumbleweed

      If you write

      $rsearch(text,)
      

      in the file naming script and then move the cursor between the comma and the closing parenthesis and start writing a regular expression like 

      [a-z]
      

      then picard crashes as soon as the '[' character is entered, since it tries to parse the regular expression and the re module raises the following exception

      Traceback (most recent call last): 
        File "/usr/lib64/python3.6/site-packages/picard/ui/options/renaming.py", line 130, in check_formats 
          self.update_examples() 
        File "/usr/lib64/python3.6/site-packages/picard/ui/options/renaming.py", line 160, in update_examples 
          example1 = self._example_to_filename(self.example_1()) 
        File "/usr/lib64/python3.6/site-packages/picard/ui/options/renaming.py", line 148, in _example_to_filename 
          filename = file._make_filename(file.filename, file.metadata, settings) 
        File "/usr/lib64/python3.6/site-packages/picard/file.py", line 349, in _make_filename 
          new_filename = self._script_to_filename(naming_format, metadata, settings) 
        File "/usr/lib64/python3.6/site-packages/picard/file.py", line 309, in _script_to_filename 
          filename = ScriptParser().eval(naming_format, metadata, self) 
        File "/usr/lib64/python3.6/site-packages/picard/script.py", line 285, in eval 
          return ScriptParser._cache[key].eval(self) 
        File "/usr/lib64/python3.6/site-packages/picard/script.py", line 123, in eval 
          result.append(item.eval(state)) 
        File "/usr/lib64/python3.6/site-packages/picard/script.py", line 115, in eval 
          return function(parser, *args) 
        File "/usr/lib64/python3.6/site-packages/picard/script.py", line 447, in func_rsearch 
          match = re.search(pattern, text) 
        File "/usr/lib64/python3.6/re.py", line 182, in search 
          return _compile(pattern, flags).search(string) 
        File "/usr/lib64/python3.6/re.py", line 301, in _compile 
          p = sre_compile.compile(pattern, flags) 
        File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile 
          p = sre_parse.parse(p, flags) 
        File "/usr/lib64/python3.6/sre_parse.py", line 855, in parse 
          p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0) 
        File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub 
          not nested and not items)) 
        File "/usr/lib64/python3.6/sre_parse.py", line 523, in _parse 
          source.tell() - here) 
      sre_constants.error: unterminated character set at position 0 
      Aborted (core dumped)
      

      This can be reproduced every time with those steps (but it doesn't happen if the closing parenthesis is not there).

            antlarr Antonio Larrosa Jiménez
            antlarr Antonio Larrosa Jiménez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package
                2.1