lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello!

I have a small lexical question.
'[[ ]]' syntax is poorly described in manual.

I am getting string from a user to  run it in sandbox.
I am concatenating users code to my code like:

"user_code=[["+user code here+"]]"+
"run_in_sandbox(user_code)"

but i want possibility of user code itself containing '[[' or ']]'.
How can i escape this chars?
To be more clear, something like that:

variable = [[ blahblah \[\[ blahblah ]]

will result variable containing " blahblah \[\[ blahblah " but i want it to contain " blahblah [[ blahblah "

And by the way, is this way of concatenating 100% safe of any code injections? Can only "]]" end string beginning with "[["?


Thanks in advance.