Skip to content

Commit

Permalink
Match escaped square brackets in paths literally not as regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Jul 7, 2023
1 parent 3b55be9 commit 8861b29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ def glob(self, path, **kwargs):
)
pattern = re.sub("[*]{2}", "=PLACEHOLDER=", pattern)
pattern = re.sub("[*]", "[^/]*", pattern)

# Replace \\[ with \[ and \\] with \], which ensures that user-specified
# escaped square brackets are matched literally and not as regexes.
pattern = re.sub(r"\\\\([\[\]])", r"\\\1", pattern)

pattern = re.compile(pattern.replace("=PLACEHOLDER=", ".*"))
out = {
p: allpaths[p]
Expand Down

0 comments on commit 8861b29

Please sign in to comment.