[verified] sanitize peer chat/control/bidi before store and TUI render
Some checks failed
ci / test (pull_request) Failing after 2m2s
Some checks failed
ci / test (pull_request) Failing after 2m2s
Strip C0 (except tab/newline), DEL, C1, and bidi/format marks at ingest and render; keep ZWJ; lossy UTF-8 stays U+FFFD. Reject the same set in fil names. Docs match the policy.
This commit is contained in:
parent
cb91ba2b78
commit
e3738c51f7
9 changed files with 181 additions and 5 deletions
|
|
@ -10,6 +10,7 @@ use rand::RngCore;
|
|||
use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::frame;
|
||||
use crate::sanitize;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ pub fn safe_name(name: &str) -> Result<&str> {
|
|||
|| name.contains('\n')
|
||||
|| name == ".."
|
||||
|| name == "."
|
||||
|| name.chars().any(sanitize::is_control_or_bidi)
|
||||
{
|
||||
return Err(Error("bad file name".into()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue