From cd7df91ce0be4563b6329e971c6544af3c88c22b Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 29 Jan 2014 13:24:30 +0000 Subject: [PATCH] Fix a bug introduced in r32678 string.gsub returns 2 values, the new string and the number of replacements made. It also has a 4th argument, the number of replacements to make. So when you use the return value of gsub as the 3rd argument, and no replacements were made, it instructs the next call to not make any replacements. Thanks to Ron Bowes for reporting this issue. --- nse_main.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nse_main.lua b/nse_main.lua index b64b57e7d..cdae16b27 100644 --- a/nse_main.lua +++ b/nse_main.lua @@ -317,7 +317,8 @@ do local against = against_name(self.host, self.port); local function replace(fmt, pattern, repl) -- Escape each % twice: once for gsub, and once for print_debug. - return gsub(fmt, pattern, gsub(repl, "%%", "%%%%%%%%")); + local r = gsub(repl, "%%", "%%%%%%%%") + return gsub(fmt, pattern, r); end if debugging() > 1 then fmt = replace(fmt, "%%THREAD_AGAINST", self.info..against);