bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.62k stars 59 forks source link

text/plain does not cover text/plain;charset=utf8 #143

Open RuijieYu opened 2 years ago

RuijieYu commented 2 years ago

I noticed that when the copied content is of MIME type text/plain;charset=utf-8, I cannot paste using MIME type text/plain, yet I can paste using MIME type text. Is this an intended behavior?

As an example:

$ paste_test() { wl-paste -l; wl-paste -t "$1" 2>/dev/null | wc -c; }
$ paste_test text/plain
text/plain;charset=utf-8
UTF8_STRING
0
$ paste_test 'text/plain;charset=utf-8'
text/plain;charset=utf-8
UTF8_STRING
7

In contrast, I can paste with MIME type text:

$ paste_test text
text/plain;charset=utf-8
UTF8_STRING
7

Edit: the content was copied from a terminal window (alacritty), which only offers the two MIME types as shown above. Edit 2: I think this tangentially relates to #71, and I am curious why this snippet has no effect on my scenario.

YaLTeR commented 2 years ago

Yeah, this is kind of intentional. There's a check in the code for the text MIME type, in which case it tries a few text-like types. I can see it useful to enable this check for text/plain as well, however, I don't remember what the original reasoning was for not doing that, and whether there was an original reasoning in the first place. For what it's worth, in my wl-clipboard-rs I'm pretty sure this behavior is the same as the current in wl-clipboard, from a quick glance at the code.