[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: finding keys in a table
- From: "Kristofer Karlsson" <kristofer.karlsson@...>
- Date: Thu, 21 Feb 2008 20:19:50 +0100
This variant takes care of those cases quite neatly, while preserving
ease of use for most cases.
function escape(s) return "[[" .. s:gsub("%]%]", "]]..']]'..[[") .. "]]" end
On Thu, Feb 21, 2008 at 6:49 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> > I guess I don't consider that a use case for s:format("%q") but rather a
> > use case for io.write('[[' .. s .. ']]').
>
> If s comes from user input, then this is unsafe if later loaded back into Lua:
> s might be "]]; MALICIOUS CODE HERE ; [[" or something like that.
>