diff --git a/client/Mac/Clipboard.m b/client/Mac/Clipboard.m index 0cd3546e3..cd7d93943 100644 --- a/client/Mac/Clipboard.m +++ b/client/Mac/Clipboard.m @@ -201,6 +201,11 @@ int mac_cliprdr_server_format_list(CliprdrClientContext* cliprdr, CLIPRDR_FORMAT mac_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT); break; } + else if (format->formatId == CF_OEMTEXT) + { + mac_cliprdr_send_client_format_data_request(cliprdr, CF_OEMTEXT); + break; + } else if (format->formatId == 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); - if ((formatId == CF_TEXT) || (formatId == CF_UNICODETEXT)) + if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) || (formatId == CF_UNICODETEXT)) { formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING"); 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]; free(data); diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 42c6dbe2d..0674d45d1 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -755,10 +755,13 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type) formatData = [item dataForType:type]; 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]; + data[size] = '\0'; + size++; ClipboardSetData(mfc->clipboard, formatId, (void*) data, size); formatMatch = TRUE;