aboutsummaryrefslogtreecommitdiffstats
path: root/util/format.lua
Commit message (Collapse)AuthorAgeFilesLines
* util.format: Fix typo in comment [codespell]Kim Alvefur2022-02-041-1/+1
|
* util.format: Expand explanation of purpose in commentsKim Alvefur2022-01-271-1/+6
|
* util.format: Skip control code escaping when doing full serializationKim Alvefur2022-01-271-1/+1
| | | | | | 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.
* util.format: Optimize most common integer formatKim Alvefur2021-12-131-0/+2
| | | | | | A search for log formats in use points to %s being the most common, followed by %d, so worth having a fast path for that. %g works well with most numbers and is what Lua 5.1 and 5.2 used
* util.format: Ensure metatable __tostring results are also sanitizedKim Alvefur2021-12-131-1/+2
|
* util.format: Fix some formats expecting positive numbers in Lua 5.2Kim Alvefur2021-12-111-0/+5
| | | | Amazing how string.format behaves differently under each Lua version
* util.format: Fix Lua 5.1 quirks thanks to ALL THE TESTSKim Alvefur2021-12-111-1/+6
|
* util.format: Also handle the %p format added in Lua 5.4Kim Alvefur2021-12-111-3/+18
|
* util.format: Ensure sanitation of strings passed to wrong formatKim Alvefur2021-12-111-21/+37
| | | | | | | | | 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.
* util.format: Escape invalid UTF-8 by passing trough serializationKim Alvefur2021-12-101-1/+10
| | | | | | 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.
* util.format: Escape ASCII control characters also in extra argumentsKim Alvefur2021-07-031-1/+1
|
* util.format: Allow newlines but ensure following lines are indentedKim Alvefur2021-07-031-1/+1
| | | | | This should a) prevent injection of text that looks like legitimate log lines and b) not mangle tracebacks.
* util.format: Fix missing backslash in patternKim Alvefur2021-07-031-1/+1
| | | | | Made the pattern match a longer range than intended, but with no effect since those characters are not present in the 'control_symbols' table.
* util.format: Change formatting of nil values to avoid looking like XMLKim Alvefur2021-06-291-2/+2
|
* util.format: Escape ASCII control characters in outputKim Alvefur2021-06-151-1/+16
| | | | | | | This should offer some protection against doing evil things to terminals. Doesn't protect against pure broken UTF-8 garbage however. See #734
* util.format: Handle integer formats the same way on Lua versions without ↵Kim Alvefur2019-05-301-2/+5
| | | | integer support
* util.format: Handle formats expecting an integer in Lua 5.3+ (fixes #1371)Kim Alvefur2019-05-301-0/+6
|
* util.format: Serialize values for the %q formatKim Alvefur2018-10-121-1/+5
| | | | Improves eg debug logs
* util.format: Use pack from util.tableKim Alvefur2018-12-081-2/+3
|
* util.format: Tweak how nil values are handledKim Alvefur2018-11-281-5/+4
| | | | Because [<nil>] seems exsessive
* util.format: Import unpack from table lib in Lua 5.2+Kim Alvefur2017-11-231-1/+1
|
* util.format: Move tests to spec/Kim Alvefur2017-11-101-10/+0
|
* util: Various minor changes to please [luacheck]Kim Alvefur2017-11-101-4/+4
|
* util.format: A string.format wrapper that gracefully handles invalid argumentsWaqas Hussain2017-09-101-0/+74