Skip to content

Commit

Permalink
Escape path before globbing (#61)
Browse files Browse the repository at this point in the history
If file names include e.g. '[' or ']', fnmatch, which is used by glob,
might throw a bad character range exception in re.

Escaping the path with glob.escape() before globbing prevents this
issue.
  • Loading branch information
jm-duke authored and amietn committed Apr 4, 2019
1 parent 7dd1d01 commit 32b5ed6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vcsi/vcsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from collections import namedtuple
from enum import Enum
from glob import glob
from glob import escape

from PIL import Image, ImageDraw, ImageFont
import numpy
Expand Down Expand Up @@ -1445,7 +1446,7 @@ def main():
if not os.path.isdir(abs_filepath):
process_file(abs_filepath, args)
else:
files_to_process = glob(path)
files_to_process = glob(escape(path))
if len(files_to_process) == 0:
files_to_process = [path]
for filename in files_to_process:
Expand Down

0 comments on commit 32b5ed6

Please sign in to comment.