FPtje / GLuaFixer

Linter for Garry's mod Lua.
https://fptje.github.io/glualint-web/
GNU Lesser General Public License v2.1
142 stars 19 forks source link

Error when using `\z` while the code runs fine #146

Closed wrefgtzweve closed 1 year ago

wrefgtzweve commented 1 year ago

Example code

print("\z5")

image

However it works when ran image

FPtje commented 1 year ago

Oh wow, this is a very obscure feature of Lua. I had to go scour into luajit's source code to even find what it means. The \z escape character, which isn't even in the PIL, tells the lexer to ignore any further whitespace.

That means that this:

print("a\z     b\z

c")

Is not only valid Lua, it prints abc. Without the \z before the newline, you'd get an error about an unfinished string, but with the \z, the whitespace is ignored on lexing level

That is very sneaky. I'll look at how this can be fixed in glualint :+1:

FPtje commented 1 year ago

Side question for curiosity, how did you come to know about this feature? I don't see it documented anywhere.

FPtje commented 1 year ago

I see that this is a continuation of #100, where support was added for \z. It looks like this works fine when you actually put whitespace after the \z, but not when you place any other character.

FPtje commented 1 year ago

Thanks for reporting! Fixed in https://github.com/FPtje/GLuaFixer/releases/tag/1.24.3!

wrefgtzweve commented 1 year ago

Side question for curiosity, how did you come to know about this feature? I don't see it documented anywhere.

some random backdoored addon had obfuscated code in it using these symbols