diff options
author | Pierre Ossman <ossman@cendio.se> | 2019-05-02 12:32:03 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2019-07-01 10:38:35 +0200 |
commit | 546b2ad80a68e80a737aade06f0685cccb5e9716 (patch) | |
tree | 60c577e30c103c16175047ea11c2bcee2b101258 /vncviewer | |
parent | 2ff61a285efda80cca7f1855aca23b99149bac8c (diff) | |
download | tigervnc-546b2ad80a68e80a737aade06f0685cccb5e9716.tar.gz tigervnc-546b2ad80a68e80a737aade06f0685cccb5e9716.zip |
Make sure clipboard uses \n line endings
This is required by the protocol so we should make sure it is
enforced. We are tolerant of clients that violate this though and
convert incoming clipboard data.
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/Viewport.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 5df5c796..15a3ec42 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * Copyright 2011-2014 Pierre Ossman for Cendio AB + * Copyright 2011-2019 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -549,7 +549,7 @@ void Viewport::resize(int x, int y, int w, int h) int Viewport::handle(int event) { - char *buffer; + char *buffer, *filtered; int ret; int buttonMask, wheelMask; DownMap::const_iterator iter; @@ -564,22 +564,26 @@ int Viewport::handle(int event) ret = fl_utf8toa(Fl::event_text(), Fl::event_length(), buffer, Fl::event_length() + 1); assert(ret < (Fl::event_length() + 1)); + filtered = convertLF(buffer, ret); + delete [] buffer; if (!hasFocus()) { - pendingClientCutText = buffer; + pendingClientCutText = new char[strlen(filtered) + 1]; + strcpy((char*)pendingClientCutText, filtered); + strFree(filtered); return 1; } - vlog.debug("Sending clipboard data (%d bytes)", (int)strlen(buffer)); + vlog.debug("Sending clipboard data (%d bytes)", (int)strlen(filtered)); try { - cc->writer()->writeClientCutText(buffer, ret); + cc->writer()->writeClientCutText(filtered, strlen(filtered)); } catch (rdr::Exception& e) { vlog.error("%s", e.str()); exit_vncviewer(e.str()); } - delete [] buffer; + strFree(filtered); return 1; |