mirror of
https://github.com/mikedilger/chorus.git
synced 2026-08-31 07:31:01 +00:00
Comments about NIP-01 violations
This commit is contained in:
parent
cdf202c3f3
commit
609aa66b4d
@ -38,6 +38,8 @@ pub fn json_escape(input: &[u8], out: &mut [u8]) -> Result<usize, Error> {
|
|||||||
if codepoint > 0x20 {
|
if codepoint > 0x20 {
|
||||||
panic!("unnecessary encoding requested");
|
panic!("unnecessary encoding requested");
|
||||||
}
|
}
|
||||||
|
// This violates NIP-01 which doesn't allow characters like 0x00
|
||||||
|
// even though JSON UTF-8 does.
|
||||||
output(format!("\\u{:04x}", codepoint).as_bytes())?;
|
output(format!("\\u{:04x}", codepoint).as_bytes())?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,6 +116,7 @@ pub fn json_unescape(input: &[u8], out: &mut [u8]) -> Result<(usize, usize), Err
|
|||||||
b'n' => output_byte!(LINEFEED, out, &mut write_pos)?,
|
b'n' => output_byte!(LINEFEED, out, &mut write_pos)?,
|
||||||
b'r' => output_byte!(CR, out, &mut write_pos)?,
|
b'r' => output_byte!(CR, out, &mut write_pos)?,
|
||||||
b't' => output_byte!(TAB, out, &mut write_pos)?,
|
b't' => output_byte!(TAB, out, &mut write_pos)?,
|
||||||
|
// This violates NIP-01 but we accept it
|
||||||
b'u' => uescape = Some((0, 0)),
|
b'u' => uescape = Some((0, 0)),
|
||||||
_ => return Err(ChorusError::JsonEscape.into()), // nothing else is a legal escape
|
_ => return Err(ChorusError::JsonEscape.into()), // nothing else is a legal escape
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user