From ad64d7af05358c4709a2b973ef3a3a9660a98beb Mon Sep 17 00:00:00 2001 From: rxi Date: Wed, 19 Mar 2014 20:14:48 +0000 Subject: [PATCH] Fixed use of pattern special chars in lume.trim() Using lua pattern special chars in the `chars` argument of lume.trim() are now handled correctly and treated like any other character. --- lume.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lume.lua b/lume.lua index db796c3..b83db7f 100644 --- a/lume.lua +++ b/lume.lua @@ -288,7 +288,8 @@ end function lume.trim(str, chars) - chars = chars or "%s" + if not chars then return str:match("^[%s]*(.-)[%s]*$") end + chars = chars:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%1") return str:match("^[" .. chars .. "]*(.-)[" .. chars .. "]*$") end