fix(plugins): do not detach if using a slash in a session name (#3839)
This commit is contained in:
parent
581e8b73ee
commit
a489b2166c
3 changed files with 46 additions and 17 deletions
|
|
@ -462,6 +462,9 @@ impl State {
|
|||
// through the package)
|
||||
self.show_error("Session name must be shorter than 108 bytes");
|
||||
return;
|
||||
} else if self.new_session_info.name().contains('/') {
|
||||
self.show_error("Session name cannot contain '/'");
|
||||
return;
|
||||
}
|
||||
self.new_session_info.handle_selection(&self.session_name);
|
||||
},
|
||||
|
|
@ -483,6 +486,10 @@ impl State {
|
|||
self.show_error("A resurrectable session by this name already exists.");
|
||||
return; // s that we don't hide self
|
||||
} else {
|
||||
if renaming_session_name.contains('/') {
|
||||
self.show_error("Session names cannot contain '/'");
|
||||
return;
|
||||
}
|
||||
self.update_current_session_name_in_ui(&renaming_session_name);
|
||||
rename_session(&renaming_session_name);
|
||||
return; // s that we don't hide self
|
||||
|
|
|
|||
|
|
@ -891,6 +891,16 @@ pub fn render_renaming_session_screen(
|
|||
33 + new_session_name.width()..40 + new_session_name.width(),
|
||||
);
|
||||
print_text_with_coordinates(text, x, y, None, None);
|
||||
if new_session_name.contains('/') {
|
||||
let error_text = "Error: session name cannot contain '/'";
|
||||
print_text_with_coordinates(
|
||||
Text::new(error_text).color_range(3, ..),
|
||||
x,
|
||||
y + 2,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_controls_line(
|
||||
|
|
|
|||
|
|
@ -1142,6 +1142,13 @@ fn switch_session(
|
|||
return Err(anyhow!("Failed to deserialize layout: {}", e));
|
||||
}
|
||||
}
|
||||
if session_name
|
||||
.as_ref()
|
||||
.map(|s| s.contains('/'))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
log::error!("Session names cannot contain \'/\'");
|
||||
} else {
|
||||
let client_id = env.client_id;
|
||||
let tab_position = tab_position.map(|p| p + 1); // ¯\_()_/¯
|
||||
let connect_to_session = ConnectToSession {
|
||||
|
|
@ -1157,6 +1164,7 @@ fn switch_session(
|
|||
client_id,
|
||||
))
|
||||
.with_context(err_context)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -1437,8 +1445,12 @@ fn rename_tab(env: &PluginEnv, tab_index: u32, new_name: &str) {
|
|||
|
||||
fn rename_session(env: &PluginEnv, new_session_name: String) {
|
||||
let error_msg = || format!("failed to rename session in plugin {}", env.name());
|
||||
if new_session_name.contains('/') {
|
||||
log::error!("Session names cannot contain \'/\'");
|
||||
} else {
|
||||
let action = Action::RenameSession(new_session_name);
|
||||
apply_action!(action, error_msg, env);
|
||||
}
|
||||
}
|
||||
|
||||
fn disconnect_other_clients(env: &PluginEnv) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue