From e5edb770e792e6e0704ea39cb8269c140e6d72a9 Mon Sep 17 00:00:00 2001 From: Vhyrro Date: Thu, 26 Oct 2023 18:40:09 +0200 Subject: [PATCH] fix: installation would fail on rocks with special characters For instance `haskell-tools.nvim` would fail to load as its name would be interpreted as a lua pattern. --- lua/rocks/operations.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/rocks/operations.lua b/lua/rocks/operations.lua index d4d9abc4..dfcef3de 100644 --- a/lua/rocks/operations.lua +++ b/lua/rocks/operations.lua @@ -48,7 +48,9 @@ operations.install = function(name, version) else future.set({ name = name, - version = obj.stdout:match(name .. "%s+(%d+%.%d+%.%d+%-%d+)"), + -- The `gsub` makes sure to escape all punctuation characters + -- so they do not get misinterpeted by the lua pattern engine. + version = obj.stdout:match(name:gsub("%p", "%%%1") .. "%s+(%d+%.%d+%.%d+%-%d+)"), }) end end)