Software /
code /
prosody
Comparison
spec/util_format_spec.lua @ 11638:5f4a657136bc
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
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 15 Jun 2021 23:24:23 +0200 |
parent | 10035:386f085820e6 |
child | 11644:fc1b8fe94d04 |
comparison
equal
deleted
inserted
replaced
11637:19cddf92fcc2 | 11638:5f4a657136bc |
---|---|
13 assert.equal("% [true]", format("%%", true)); | 13 assert.equal("% [true]", format("%%", true)); |
14 assert.equal("{ }", format("%q", { })); | 14 assert.equal("{ }", format("%q", { })); |
15 assert.equal("[1.5]", format("%d", 1.5)); | 15 assert.equal("[1.5]", format("%d", 1.5)); |
16 assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464)); | 16 assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464)); |
17 end); | 17 end); |
18 | |
19 it("escapes ascii control stuff", function () | |
20 assert.equal("␁", format("%s", "\1")); | |
21 end); | |
22 | |
18 end); | 23 end); |
19 end); | 24 end); |