aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJae-Heon Ji <32578710+jaeheonji@users.noreply.github.com>2022-01-25 22:11:31 +0900
committerGitHub <noreply@github.com>2022-01-25 22:11:31 +0900
commit8d224cb84a7f79736d7aed39af277df2454982e0 (patch)
tree467124149fd9ec8ea930f0fbe78754cce934cc7b
parentdocs(changelog): update parsing crate to clap v3.0 (diff)
downloadsl0ppij-8d224cb84a7f79736d7aed39af277df2454982e0.tar.gz
sl0ppij-8d224cb84a7f79736d7aed39af277df2454982e0.tar.xz
sl0ppij-8d224cb84a7f79736d7aed39af277df2454982e0.zip
feat: accept only printable unicode char (#1016)
* feat: accept only printable unicode char * chore: revert comments
-rw-r--r--zellij-server/src/screen.rs7
-rw-r--r--zellij-server/src/tab/mod.rs9
2 files changed, 12 insertions, 4 deletions
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 71ae0805..c8f80eba 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -611,11 +611,14 @@ impl Screen {
active_tab.name = String::new();
}
"\u{007F}" | "\u{0008}" => {
- //delete and backspace keys
+ // delete and backspace keys
active_tab.name.pop();
}
c => {
- active_tab.name.push_str(c);
+ // It only allows printable unicode
+ if buf.iter().all(|u| matches!(u, 0x20..=0x7E)) {
+ active_tab.name.push_str(c);
+ }
}
}
self.update_tabs();
diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs
index cc83d37c..6818653d 100644
--- a/zellij-server/src/tab/mod.rs
+++ b/zellij-server/src/tab/mod.rs
@@ -1998,12 +1998,17 @@ impl Tab {
pub fn update_active_pane_name(&mut self, buf: Vec<u8>, client_id: ClientId) {
if let Some(active_terminal_id) = self.get_active_terminal_id(client_id) {
- let s = str::from_utf8(&buf).unwrap();
let active_terminal = self
.panes
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
- active_terminal.update_name(s);
+
+ // It only allows printable unicode, delete and backspace keys.
+ let is_updatable = buf.iter().all(|u| matches!(u, 0x20..=0x7E | 0x08 | 0x7F));
+ if is_updatable {
+ let s = str::from_utf8(&buf).unwrap();
+ active_terminal.update_name(s);
+ }
}
}