mfreerdp: fix clipboard missing last character and extra last character

This commit is contained in:
Marc-André Moreau 2014-12-21 14:17:51 -05:00
parent e6eeae2ddd
commit 1e7941297e
2 changed files with 15 additions and 3 deletions

View File

@ -201,6 +201,11 @@ int mac_cliprdr_server_format_list(CliprdrClientContext* cliprdr, CLIPRDR_FORMAT
mac_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT); mac_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT);
break; break;
} }
else if (format->formatId == CF_OEMTEXT)
{
mac_cliprdr_send_client_format_data_request(cliprdr, CF_OEMTEXT);
break;
}
else if (format->formatId == CF_TEXT) else if (format->formatId == CF_TEXT)
{ {
mac_cliprdr_send_client_format_data_request(cliprdr, CF_TEXT); mac_cliprdr_send_client_format_data_request(cliprdr, CF_TEXT);
@ -305,11 +310,15 @@ int mac_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr, CLIPR
SetEvent(mfc->clipboardRequestEvent); SetEvent(mfc->clipboardRequestEvent);
if ((formatId == CF_TEXT) || (formatId == CF_UNICODETEXT)) if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) || (formatId == CF_UNICODETEXT))
{ {
formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING"); formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING");
data = (void*) ClipboardGetData(mfc->clipboard, formatId, &size); data = (void*) ClipboardGetData(mfc->clipboard, formatId, &size);
if (size > 1)
size--; /* we need the size without the null terminator */
NSString* str = [[NSString alloc] initWithBytes: (void*) data length:size encoding:NSUTF8StringEncoding]; NSString* str = [[NSString alloc] initWithBytes: (void*) data length:size encoding:NSUTF8StringEncoding];
free(data); free(data);

View File

@ -755,10 +755,13 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
formatData = [item dataForType:type]; formatData = [item dataForType:type];
formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING"); formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING");
size = (UINT32) [formatData length]; /* length does not include null terminator */
data = (BYTE*) malloc(size); size = (UINT32) [formatData length];
data = (BYTE*) malloc(size + 1);
[formatData getBytes:data length:size]; [formatData getBytes:data length:size];
data[size] = '\0';
size++;
ClipboardSetData(mfc->clipboard, formatId, (void*) data, size); ClipboardSetData(mfc->clipboard, formatId, (void*) data, size);
formatMatch = TRUE; formatMatch = TRUE;