diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2013-04-12 22:56:30 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-04-12 22:56:30 -0300 |
commit | 26db61478504c7b13099b942aeebbdd6ffa4472b (patch) | |
tree | 5d335945e65ac24bb8e479e36514d001c8ba53e2 | |
parent | 736fa98402202f74160e0bd7cfe7745e34b307ab (diff) | |
download | luarocks-26db61478504c7b13099b942aeebbdd6ffa4472b.tar.gz luarocks-26db61478504c7b13099b942aeebbdd6ffa4472b.tar.bz2 luarocks-26db61478504c7b13099b942aeebbdd6ffa4472b.zip |
Safe quoting for concatenating constant strings into patterns.
-rw-r--r-- | src/luarocks/build/builtin.lua | 2 | ||||
-rw-r--r-- | src/luarocks/util.lua | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index f9cc0302..3d179b34 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -223,7 +223,7 @@ function run(rockspec) | |||
223 | table.insert(objects, object) | 223 | table.insert(objects, object) |
224 | end | 224 | end |
225 | if not ok then break end | 225 | if not ok then break end |
226 | local module_name = dir.path(moddir, name:match("([^.]*)$").."."..cfg.lib_extension):gsub("//", "/") | 226 | local module_name = dir.path(moddir, name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension)):gsub("//", "/") |
227 | if moddir ~= "" then | 227 | if moddir ~= "" then |
228 | fs.make_dir(moddir) | 228 | fs.make_dir(moddir) |
229 | end | 229 | end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index c6e0c592..c44dc73d 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -52,6 +52,15 @@ function run_scheduled_functions() | |||
52 | end | 52 | end |
53 | end | 53 | end |
54 | 54 | ||
55 | --- Produce a Lua pattern that matches precisely the given string | ||
56 | -- (this is suitable to be concatenating to other patterns, | ||
57 | -- so it does not include beginning- and end-of-string markers (^$) | ||
58 | -- @param s string: The input string | ||
59 | -- @return string: The equivalent pattern | ||
60 | function matchquote(s) | ||
61 | return (s:gsub("[?%-+*%[%].%%()$^]","%%%1")) | ||
62 | end | ||
63 | |||
55 | --- Extract flags from an arguments list. | 64 | --- Extract flags from an arguments list. |
56 | -- Given string arguments, extract flag arguments into a flags set. | 65 | -- Given string arguments, extract flag arguments into a flags set. |
57 | -- For example, given "foo", "--tux=beep", "--bla", "bar", "--baz", | 66 | -- For example, given "foo", "--tux=beep", "--bla", "bar", "--baz", |