Skip to content

Commit

Permalink
Fix ranges in globbing
Browse files Browse the repository at this point in the history
Always escaping and discarding first character in a class is
not correct when it's part of a range, e.g. '[a-z]'.
  • Loading branch information
mpeterv committed Jul 17, 2015
1 parent 96131c6 commit da8dbb9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/luacheck/globbing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ local function glob_part_to_pattern(glob_part)

if first_char == "!" then
table.insert(buffer, "^")
else
table.insert(buffer, "%"..first_char)
i = i + 1
elseif first_char == "]" then
table.insert(buffer, "%]")
i = i + 1
end

bracketless, i = glob_part:match("([^%]]*)()", i + 1)
bracketless, i = glob_part:match("([^%]]*)()", i)

if bracketless:sub(1, 1) == "-" then
table.insert(buffer, "%-")
Expand Down

0 comments on commit da8dbb9

Please sign in to comment.