Ticket #313: Return whatever is converted so far if EILSEQ detected. Furthermore, if NULL returned from convert(), just send an empty string. Finally, use //TRANSLIT as an option for iconv_open if the library version supports it.

This commit is contained in:
James Muehlner 2013-05-22 21:53:30 -07:00
parent 83d8630f84
commit fb74c87e23
3 changed files with 14 additions and 9 deletions

View File

@ -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([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([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([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required"))
#AC_CHECK_LIB([iconv], [iconv],, AC_MSG_ERROR("libiconv is required"))
# Checks for header files. # 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. # Checks for library functions.
AC_FUNC_MALLOC AC_FUNC_MALLOC

View File

@ -94,10 +94,8 @@ char* convert(const char* from_charset, const char* to_charset, const char* inpu
output_buffer = output + bytes_converted; output_buffer = output + bytes_converted;
} }
else if (errno == EILSEQ) { else if (errno == EILSEQ) {
/* Cannot convert because an invalid sequence was discovered */ /* Invalid sequence detected, return what's been converted so far */
iconv_close(cd); break;
free(output);
return NULL;
} }
else if (errno == EINVAL) { else if (errno == EINVAL) {
/* Incomplete sequence detected, can be ignored */ /* Incomplete sequence detected, can be ignored */

View File

@ -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; rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client;
/* Convert UTF-8 character data to ISO_8859-1 */ /* 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); char* iso_8559_1_data = convert("UTF-8", "ISO_8859-1", data);
#endif
/* 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)); SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data));
free(iso_8559_1_data); free(iso_8559_1_data);
/* Otherwise, just send an empty string. */
} else
SendClientCutText(rfb_client, "", 0);
return 0; return 0;
} }