Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set CLIPBOARD_STATE to sensitive if x-kde-passwordManagerHint is in the MIME list #204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Bwc9876
Copy link

@Bwc9876 Bwc9876 commented Nov 14, 2023

Password managers like KeepassXC pass the x-kde-passwordManagerHint MIME type to signal to clipboard applications that the information is sensitive and shouldn't be forwarded. This PR will set CLIPBOARD_STATE to sensitive if that MIME type is present.

This is my first time using C in a while so apologies if it's a bit messy, let me know if any changes are needed :)

@Lcchy
Copy link

Lcchy commented Apr 11, 2024

I was looking into preventing my passwords from being saved in my clipboard manager (cliphist), thanks for the PR!

The CLIPBOARD_STATE=sensitive part works for me although I am unable to paste as the only offered type is then "x-kde-passwordManagerHint":

$ wl-copy word --type x-kde-passwordManagerHint; wl-paste --list-types
x-kde-passwordManagerHint

I don't really know the project but I fixed it with:

diff --git a/src/wl-copy.c b/src/wl-copy.c
index b040cb6..dabc775 100644
--- a/src/wl-copy.c
+++ b/src/wl-copy.c
@@ -295,7 +295,7 @@ int main(int argc, argv_t argv) {
         if (options.mime_type != NULL) {
             source_offer(copy_action->source, options.mime_type);
         }
-        if (options.mime_type == NULL || mime_type_is_text(options.mime_type)) {
+        if (options.mime_type == NULL || mime_type_is_text(options.mime_type) || strcmp(options.mime_type, "x-kde-passwordManagerHint") == 0) {
             /* Offer a few generic plain text formats */
             source_offer(copy_action->source, text_plain);
             source_offer(copy_action->source, text_plain_utf8);

That makes the sensitive data have a few text types as a fallback.

$ wl-copy word --type x-kde-passwordManagerHint; wl-paste --list-types
x-kde-passwordManagerHint
text/plain
text/plain;charset=utf-8
TEXT
STRING
UTF8_STRING

(Referencing this issue here as it wasn't: #177)

@MrSmoer
Copy link

MrSmoer commented May 28, 2024

KeePassXC also puts the content secretunder the x-kde-passwordManagerHint MIME-Type. Maybe that should be checked here as well, in order to not introduce inconsistencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants