darkirc: bug fix caused panic when the message is not utf-8 (ie a charachter is more than one byte)

This commit is contained in:
dasman
2025-09-04 17:06:32 +03:00
parent af18f0e6bc
commit 3f4f6421cb

View File

@@ -422,10 +422,10 @@ impl Client {
let mut line = line.to_string();
// Remove CRLF
if &line[(line.len() - 2)..] == "\r\n" {
if line.ends_with("\r\n") {
line.pop();
line.pop();
} else if &line[(line.len() - 1)..] == "\n" {
} else if line.ends_with("\n") {
line.pop();
} else {
return Err(Error::ParseFailed("Line doesn't end with CR/LF"))