mime: use text/plain as a fallback
This commit is contained in:
parent
31392200dc
commit
909b7f6ff3
3 changed files with 15 additions and 3 deletions
|
|
@ -5,6 +5,7 @@
|
|||
- Update SCTK to 0.18
|
||||
- Fix active polling of the clipboard each 50ms
|
||||
- Fix freeze when copying data larger than the pipe buffer size
|
||||
- Accept text/plain mime type as a fallback
|
||||
|
||||
## 0.6.6 -- 2022-06-20
|
||||
|
||||
|
|
|
|||
13
src/mime.rs
13
src/mime.rs
|
|
@ -1,5 +1,6 @@
|
|||
/// List of allowed mimes.
|
||||
pub static ALLOWED_MIME_TYPES: [&str; 2] = ["text/plain;charset=utf-8", "UTF8_STRING"];
|
||||
pub static ALLOWED_MIME_TYPES: [&str; 3] =
|
||||
["text/plain;charset=utf-8", "UTF8_STRING", "text/plain"];
|
||||
|
||||
/// Mime type supported by clipboard.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||
|
|
@ -13,6 +14,10 @@ pub enum MimeType {
|
|||
/// Some X11 clients are using only this mime type, so we
|
||||
/// should have it as a fallback just in case.
|
||||
Utf8String = 1,
|
||||
/// text/plain mime type.
|
||||
///
|
||||
/// Fallback without charset parameter.
|
||||
TextPlain = 2,
|
||||
}
|
||||
|
||||
impl MimeType {
|
||||
|
|
@ -21,15 +26,19 @@ impl MimeType {
|
|||
/// `find_allowed()` searches for mime type clipboard supports, if we have a
|
||||
/// match, returns `Some(MimeType)`, otherwise `None`.
|
||||
pub fn find_allowed(offered_mime_types: &[String]) -> Option<Self> {
|
||||
let mut fallback = None;
|
||||
for offered_mime_type in offered_mime_types.iter() {
|
||||
if offered_mime_type == ALLOWED_MIME_TYPES[Self::TextPlainUtf8 as usize] {
|
||||
return Some(Self::TextPlainUtf8);
|
||||
} else if offered_mime_type == ALLOWED_MIME_TYPES[Self::Utf8String as usize] {
|
||||
return Some(Self::Utf8String);
|
||||
} else if offered_mime_type == ALLOWED_MIME_TYPES[Self::TextPlain as usize] {
|
||||
// Only use this mime type as a fallback.
|
||||
fallback = Some(Self::TextPlain);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
fallback
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,9 @@ impl State {
|
|||
|
||||
// Post-process the content according to mime type.
|
||||
let content = match mime_type {
|
||||
MimeType::TextPlainUtf8 => normalize_to_lf(content),
|
||||
MimeType::TextPlainUtf8 | MimeType::TextPlain => {
|
||||
normalize_to_lf(content)
|
||||
},
|
||||
MimeType::Utf8String => content,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue