diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index c40d5ca4..4ec58740 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -46,10 +46,9 @@ AC_PROG_LIBTOOL AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first")) AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) -#AC_CHECK_LIB([iconv], [iconv],, AC_MSG_ERROR("libiconv is required")) # Checks for header files. -AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/socket.h guacamole/protocol.h]) +AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/socket.h guacamole/protocol.h iconv.h]) # Checks for library functions. AC_FUNC_MALLOC diff --git a/protocols/vnc/src/convert.c b/protocols/vnc/src/convert.c index 7becb34c..8bc9e8d0 100644 --- a/protocols/vnc/src/convert.c +++ b/protocols/vnc/src/convert.c @@ -94,10 +94,8 @@ char* convert(const char* from_charset, const char* to_charset, const char* inpu output_buffer = output + bytes_converted; } else if (errno == EILSEQ) { - /* Cannot convert because an invalid sequence was discovered */ - iconv_close(cd); - free(output); - return NULL; + /* Invalid sequence detected, return what's been converted so far */ + break; } else if (errno == EINVAL) { /* Incomplete sequence detected, can be ignored */ diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c index c456baae..67e94b96 100644 --- a/protocols/vnc/src/guac_handlers.c +++ b/protocols/vnc/src/guac_handlers.c @@ -95,11 +95,19 @@ int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; /* Convert UTF-8 character data to ISO_8859-1 */ + # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 || _LIBICONV_VERSION >= 0x0105 + char* iso_8559_1_data = convert("UTF-8", "ISO_8859-1//TRANSLIT", data); + #else char* iso_8559_1_data = convert("UTF-8", "ISO_8859-1", data); + #endif - SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data)); - - free(iso_8559_1_data); + /* If the conversion was successful, send the converted character data. */ + if(iso_8559_1_data) { + SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data)); + free(iso_8559_1_data); + /* Otherwise, just send an empty string. */ + } else + SendClientCutText(rfb_client, "", 0); return 0; }