lua-users home
lua-l archive

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

> There are three possible issues here;
> 1) Not quite complete documentation of '%' in string.gsub replacements

The documentaion should say what any implementation should do, not what
one particular implementation does. Cases like '%a' are left undefined
on purpose. (For instance, we may add extra cases without breaking
compatibility.)  Of course, the current implementation could
be more polite by pointing out when the program uses an undefined
behavior. (But this should not be documented either ;)

> 2) string.gsub reading beyond the end of the replacement string
> (although this is never a buffer overflow as there is always a NULL
> just beyond the end of strings in the current implementation)

This is a particular case o 1. The behavior of a '%' in the end of the
replacement is undefined.

> 3) print(s) to stdout stopping at any embedded NULL characters

This may be trickier than it seems. Several other characters cause
problems when printed without treatment (e.g., backspace). To handle
them, we must know what the terminal considers a special character.
But the terminal may use a locale different from the one used by the

-- Roberto