Software /
code /
prosody
Comparison
spec/util_format_spec.lua @ 12031:87bc26f23d9b
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 10 Dec 2021 22:48:45 +0100 |
parent | 11644:fc1b8fe94d04 |
child | 12032:3db09eb4c43b |
comparison
equal
deleted
inserted
replaced
12030:9f8206e99b89 | 12031:87bc26f23d9b |
---|---|
18 | 18 |
19 it("escapes ascii control stuff", function () | 19 it("escapes ascii control stuff", function () |
20 assert.equal("␁", format("%s", "\1")); | 20 assert.equal("␁", format("%s", "\1")); |
21 end); | 21 end); |
22 | 22 |
23 it("escapes invalid UTF-8", function () | |
24 assert.equal("\"Hello w\\195rld\"", format("%s", "Hello w\195rld")); | |
25 end); | |
26 | |
23 end); | 27 end); |
24 end); | 28 end); |