summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2019-05-02 12:32:03 +0200
committerPierre Ossman <ossman@cendio.se>2019-07-01 10:38:35 +0200
commit546b2ad80a68e80a737aade06f0685cccb5e9716 (patch)
tree60c577e30c103c16175047ea11c2bcee2b101258 /win
parent2ff61a285efda80cca7f1855aca23b99149bac8c (diff)
downloadtigervnc-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 'win')
-rw-r--r--win/rfb_win32/Clipboard.cxx16
1 files changed, 2 insertions, 14 deletions
diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx
index 0e290623..fca6c1df 100644
--- a/win/rfb_win32/Clipboard.cxx
+++ b/win/rfb_win32/Clipboard.cxx
@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2012-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
@@ -35,18 +36,6 @@ static LogWriter vlog("Clipboard");
//
char*
-dos2unix(const char* text) {
- int len = strlen(text)+1;
- char* unix = new char[strlen(text)+1];
- int i, j=0;
- for (i=0; i<len; i++) {
- if (text[i] != '\x0d')
- unix[j++] = text[i];
- }
- return unix;
-}
-
-char*
unix2dos(const char* text) {
int len = strlen(text)+1;
char* dos = new char[strlen(text)*2+1];
@@ -126,8 +115,7 @@ Clipboard::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
if (!clipdata) {
notifier->notifyClipboardChanged(0, 0);
} else {
- CharArray unix_text;
- unix_text.buf = dos2unix(clipdata);
+ CharArray unix_text(convertLF(clipdata, strlen(clipdata)));
removeNonISOLatin1Chars(unix_text.buf);
notifier->notifyClipboardChanged(unix_text.buf, strlen(unix_text.buf));
}