mirror of
https://github.com/mikedilger/chorus.git
synced 2026-03-04 06:36:27 +00:00
Fix: escape content when converting Event to json [needs a further performance tweak]
This commit is contained in:
parent
b941d67976
commit
5254a6450d
@ -118,7 +118,13 @@ impl<'a> Event<'a> {
|
||||
output.extend(br#","tags":"#);
|
||||
output.extend(self.tags()?.as_json());
|
||||
output.extend(br#","content":""#);
|
||||
output.extend(self.content());
|
||||
// FIXME: we cannot just extend with the raw content, we have to
|
||||
// json_escape it first.
|
||||
// BUT unfortunately that currently requires a malloc. We will fix
|
||||
// that in the next commit
|
||||
let mut escaped_content = vec![0; self.content().len() * 2];
|
||||
let content_outlen = json_escape(self.content(), &mut escaped_content[..])?;
|
||||
output.extend(&escaped_content[..content_outlen]);
|
||||
output.extend(br#"","sig":""#);
|
||||
let pos = output.len();
|
||||
output.resize(pos + 128, 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user