lua-users home
lua-l archive

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


Am 18.08.2014 um 03:00 schrieb William Ahern:
On Sun, Aug 17, 2014 at 09:45:43PM -0300, Thiago L. wrote:
On 17/08/14 05:17 PM, Philipp Janda wrote:
Am 17.08.2014 um 20:22 schrieb Thiago L.:
On 17/08/14 03:09 PM, Philipp Janda wrote:
Don't forget:
__tostring
I thought __tostring was a fallback... (Lua doesn't know what to do, but
instead of throwing an error it returns the memory address or a hash or
w/e)
<snip>
Or my favourite:

    debug.setmetatable( "", {
      __tostring = function( v ) return "bye bye" end
    } )
    print( "hello world" )
<snip>
Ouch... and we don't have a rawtostring()...

For numbers you can use `""..v` -- at least if you didn't disable coercions in Lua 5.3.


Sometimes I don't know what's wrong with ppl... this is one of them...

But I imagine one could implement an interesting data loss protection (DLP)
scheme using this. For example, scan the string for Social Security numbers,
phone numbers, etc. If something sensitive is in the string, then trace the
stack to make sure the request is from an allowed caller, such as a database
library, otherwise log or throw an error so the privacy leak can be closed.


Always the optimist :-)
I suppose Lua gives you the tools to make life hell for the poor guy debugging your code ...

I guess normal Lua code can ignore those gotchas, but I expect debugging tools to handle those cases (you only use those tools when your code is screwed up, and I think this qualifies ...).


Philipp