Skip to content

Commit

Permalink
#812: add a blacklist of clipboard client we just ignore (for now, ju…
Browse files Browse the repository at this point in the history
…st 'clipit'), better warning messages

git-svn-id: https://xpra.org/svn/Xpra/trunk@22470 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 19, 2019
1 parent 6fdb267 commit d189f64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/xpra/clipboard/clipboard_timeout_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,17 @@ def _send_clipboard_request_handler(self, proxy, selection, target):
request_id = self._clipboard_request_counter
self._clipboard_request_counter += 1
log("send_clipboard_request id=%s", request_id)
timer = glib.timeout_add(REMOTE_TIMEOUT, self.timeout_request, request_id)
timer = glib.timeout_add(REMOTE_TIMEOUT, self.timeout_request, request_id, selection, target)
self._clipboard_outstanding_requests[request_id] = (timer, selection, target)
self.progress()
self.send("clipboard-request", request_id, self.local_to_remote(selection), target)

def timeout_request(self, request_id):
def timeout_request(self, request_id, selection, target):
try:
selection, target = self._clipboard_outstanding_requests.pop(request_id)[1:]
except KeyError:
log.warn("Warning: request id %i not found", request_id)
log.warn("Warning: clipboard request id %i not found", request_id)
log.warn(" selection=%s, target=%s", selection, target)
return
finally:
self.progress()
Expand All @@ -98,6 +99,7 @@ def _clipboard_got_contents(self, request_id, dtype=None, dformat=None, data=Non
timer, selection, target = self._clipboard_outstanding_requests.pop(request_id)
except KeyError:
log.warn("Warning: request id %i not found", request_id)
log.warn(" timed out already?")
return
finally:
self.progress()
Expand Down
14 changes: 12 additions & 2 deletions src/xpra/x11/gtk_x11/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import os
import struct

from xpra.gtk_common.error import xsync, xswallow
Expand All @@ -26,7 +27,7 @@
X11WindowBindings, #@UnresolvedImport
)
from xpra.os_util import bytestostr
from xpra.util import csv, repr_ellipsized
from xpra.util import csv, repr_ellipsized, first_time
from xpra.log import Logger

gdk = import_gdk()
Expand All @@ -43,6 +44,8 @@

sizeof_long = struct.calcsize(b'@L')

BLACKLISTED_CLIPBOARD_CLIENTS = os.environ.get("XPRA_BLACKLISTED_CLIPBOARD_CLIENTS", "clipit").split(",")


def xatoms_to_strings(data):
l = len(data)
Expand Down Expand Up @@ -315,12 +318,19 @@ def do_selection_request_event(self, event):
log("do_selection_request_event(%s)", event)
requestor = event.requestor
assert requestor
wininfo = self.get_wininfo(get_xwindow(requestor))
log("clipboard request for %s from window %#x: %s",
self._selection, get_xwindow(requestor), self.get_wininfo(get_xwindow(requestor)))
self._selection, get_xwindow(requestor), wininfo)
prop = event.property
target = str(event.target)
def nodata():
self.set_selection_response(requestor, target, prop, "STRING", 8, b"", time=event.time)
if wininfo.startswith("'") and wininfo.endswith("'") and wininfo.strip("'") in BLACKLISTED_CLIPBOARD_CLIENTS:
if first_time("clipboard-blacklisted:%s" % wininfo.strip("'")):
log.warn("receiving clipboard requests from blacklisted client %s", wininfo)
log.warn(" all requests will be silently ignored")
nodata()
return
if not self.owned:
log.warn("Warning: clipboard selection request received,")
log.warn(" but we don't own the selection,")
Expand Down

0 comments on commit d189f64

Please sign in to comment.