From 969c72be028ead6a78928c1eea1c71da3bc94fab Mon Sep 17 00:00:00 2001 From: Frederic Laing Date: Wed, 4 Feb 2026 08:34:40 +0100 Subject: [PATCH] fix: handle invalid UTF-8 in clipboard text paste --- src/clipboard.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/clipboard.rs b/src/clipboard.rs index fd26a0e..bf84bee 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -317,9 +317,11 @@ impl TryFrom<(Vec, String)> for ClipboardPasteText { if data.is_empty() { return Err("Empty text data".into()); } - let text = str::from_utf8(&data)?; + // Use lossy conversion to handle clipboard data that may contain + // invalid UTF-8 (e.g., Latin-1 encoded special characters from browsers) + let text = String::from_utf8_lossy(&data); Ok(Self { - data: text.to_string(), + data: text.into_owned(), }) } }