| ... | @@ -233,8 +233,15 @@ impl Clipboard { | ... | @@ -233,8 +233,15 @@ impl Clipboard { |
| 233 | } | 233 | } |
| 234 | | 234 | |
| 235 | pub fn get_files(&mut self) -> Vec<std::path::PathBuf> { | 235 | pub fn get_files(&mut self) -> Vec<std::path::PathBuf> { |
| 236 | self.through_x11(|clipboard| clipboard.get().file_list().ok()) | 236 | use std::os::unix::ffi::OsStrExt; |
| 237 | .unwrap_or_default() | 237 | let files = self.through_x11(|clipboard| clipboard.get().file_list().ok()); |
| | 238 | // arboard splits text/uri-list at LF and keeps the CR its CRLF lines end in. |
| | 239 | let path = |path: std::path::PathBuf| { |
| | 240 | let bytes = path.as_os_str().as_bytes(); |
| | 241 | let bytes = bytes.strip_suffix(b"\r").unwrap_or(bytes); |
| | 242 | std::ffi::OsStr::from_bytes(bytes).into() |
| | 243 | }; |
| | 244 | files.unwrap_or_default().into_iter().map(path).collect() |
| 238 | } | 245 | } |
| 239 | | 246 | |
| 240 | pub fn get_html(&mut self) -> Option<String> { | 247 | pub fn get_html(&mut self) -> Option<String> { |