Kim Alvefur
1a2fdf3f7f
util.format: Update tests for serialization changes
3 years ago
Kim Alvefur
14fceee089
tests: Remove special-casing of Lua 5.1
...
Part of #1600
4 years ago
Kim Alvefur
c551d3d8dd
util.format: Skip control code escaping when doing full serialization
...
Fixes that a multi-line string ended up "like\
\9this" instead of "like\nthis" as can be demonstrated by somehow
initiating a connection to a HTTP server.
4 years ago
Kim Alvefur
58c9115351
util.format: Ensure metatable __tostring results are also sanitized
4 years ago
Kim Alvefur
d482ece962
util.format: Fix some formats expecting positive numbers in Lua 5.2
...
Amazing how string.format behaves differently under each Lua version
4 years ago
Kim Alvefur
3d0844a4f5
util.format: ALL THE TESTS!!!
...
The more tests I made, the more Lua 5.1 quirks I discovered.
Tests generated using a tool plus some touch-up.
4 years ago
Kim Alvefur
0ddd204a27
util.format: Also handle the %p format added in Lua 5.4
4 years ago
Kim Alvefur
1eca4e8870
util.format: Ensure sanitation of strings passed to wrong format
...
Ie. log("debug", "%d", "\1\2\3") should not result in garbage.
Also optimizing for the common case of ASCII string passed to %s and
early returns everywhere.
Returning nil from a gsub callback keeps the original substring.
4 years ago
Kim Alvefur
d4c1451794
util.format: Escape invalid UTF-8 by passing trough serialization
...
Should prevent invalid UTF-8 from making it into the logs, which can
cause trouble with terminals or log viewers or other tools, such as when
grep determines that log files are binary.
4 years ago
Kim Alvefur
6e037dc045
util.format: Change formatting of nil values to avoid looking like XML
5 years ago
Kim Alvefur
3f1d93bb4e
util.format: Escape ASCII control characters in output
...
This should offer some protection against doing evil things to
terminals. Doesn't protect against pure broken UTF-8 garbage however.
See #734
5 years ago
Kim Alvefur
2661a6f5a3
util.format: Handle integer formats the same way on Lua versions without integer support
7 years ago
Kim Alvefur
236abc4afe
util.format: Handle formats expecting an integer in Lua 5.3+ ( fixes #1371 )
7 years ago
Kim Alvefur
f45bf94518
util.format: Add test coverage for case of extra nil argument
8 years ago
Kim Alvefur
faf91e381d
util.format: Fix tests to have expected value first
8 years ago
Kim Alvefur
0c4ad0fdbc
util.format: Move tests to spec/
8 years ago
Kim Alvefur
177420df39
util.format: Serialize values for the %q format
...
Improves eg debug logs
7 years ago
Kim Alvefur
d007771f8d
util.format: Tweak how nil values are handled
...
Because [<nil>] seems exsessive
7 years ago