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:
parent
83d8630f84
commit
fb74c87e23
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user