lua-users home
lua-l archive

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


The program 'lua' prints error message that contain contextual data from the user, presumably to help debug the problem. 

In my opinion, the program 'lua' should not make any assumptions about the value of this user data, and should ensure that it does not affect the channel that the error message is sent over:
The program 'lua' might do the equivalent of string.format('q') on the user data before printing it as part of an error message. It does not matter that the format is not exactly as the user entered it, as long as it is contains an unambiguous representation of the original data.

Personally, I would prefer to see escaped value in hexadecimal rather than decimal ('\x0d' rather than '\13'), and also to see '\x0a' (or '\10') rather than the backslash-escaped newline.

This affects user data that the program 'lua' prints as part of an error message. Any data that the user program sends to any output device using the functions print() or io.write() or friends must be sent to the output device unmodified.

Stephen


On 16 August 2017 at 14:00, nobody <nobody+lua-list@afra-berlin.de> wrote:
On 2017-08-16 03:07, Soni L. wrote:
On 08/16/2017 12:34 AM, Soni L. wrote:
"hello \x1b[33m \u{"
"\x1b[1;3;4;7;32mHi!"

I'm of the opinion that error messages containing control codes should
be an error.

So what should happen?  Escape some (all?) non-printable characters? But maybe keep NL? HT? CR?

What about \0?  That currently terminates error messages:

> "foo\0bar \u{"
stdin:1: hexadecimal digit expected near '"foo'
> error "foo\0bar"
stdin:1: foo
stack traceback:
    [...]


OTOH, I _do_ like my

Error = { __tostring = function( e )  return e.msg  end }
function oops( msg )
  return error( setmetatable( {
    msg = "\x1b[1;7;31m OOPS \x1b[0;31m "..msg.."\x1b[0m",
    reason = "panic",
  }, Error ) )
end
oops "things just went horribly wrong"

so this should only affect Lua's own error messages.

-- nobody