From ce85965783a96c81ce52a1281e0fee4d34dfea89 Mon Sep 17 00:00:00 2001 From: Nicholas Hassan Date: Thu, 6 Jun 2024 14:34:48 +0930 Subject: [PATCH] fix panic on message escape --- .vscode/settings.json | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- src/helpers.rs | 10 ++++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 77b71d8..8acf622 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix", + "nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix", "terminal.integrated.defaultProfile.linux": "zsh with nix-shell", } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e84a201..8c7a7c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1078,7 +1078,7 @@ dependencies = [ [[package]] name = "telelog" -version = "0.2.1" +version = "0.2.2" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index d493cd5..aba5333 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "telelog" -version = "0.2.1" +version = "0.2.2" edition = "2021" [dependencies] diff --git a/src/helpers.rs b/src/helpers.rs index 4a99a17..94bbdb1 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -78,6 +78,7 @@ pub fn colour_translate(priority: u8) -> String { pub fn escape_message(message: &str) -> String { let mut message = message.to_string(); + if message.starts_with("") { message = message.strip_prefix("").unwrap_or("").to_string(); } @@ -86,10 +87,15 @@ pub fn escape_message(message: &str) -> String { message = message.strip_suffix("").unwrap_or("").to_string(); } - message + message = message .replace("&", "&") .replace("<", "<") .replace(">", ">") .replace("\"", """) - .replace("'", "'") + .replace("'", "'"); + + + message = "".to_string() + &message + ""; + + message } \ No newline at end of file