Fix utf8 conversion on Alpine

The iconv_open() function fails on Alpine because the musl iconv
implementation does not support //TRANSLIT.

See: https://github.com/akrennmair/newsbeuter/issues/364#issuecomment-250208235

This commit also makes it so `ctest` must pass when building the Docker
image, now that the tests with utf8 conversion are expected to pass.
pull/165/head
Micah Snyder 4 years ago
parent 6a8de8a8f7
commit 8dd90c16b4
  1. 2
      Dockerfile
  2. 9
      libclamav/entconv.c

@ -83,7 +83,7 @@ RUN apk add --no-cache \
-e "s|.*\(\ClamdSocket\) .*|\1 unix:/run/clamav/clamd.sock|" \
"/clamav/etc/clamav/clamav-milter.conf.sample" > "/clamav/etc/clamav/clamav-milter.conf" || \
exit 1 && \
ctest -V || echo "Continuing with failed tests!"
ctest -V
FROM registry.hub.docker.com/library/alpine:latest

@ -1005,8 +1005,13 @@ cl_error_t cli_codepage_to_utf8(char* in, size_t in_size, uint16_t codepage, cha
conv = iconv_open("UTF-8//TRANSLIT", encoding);
if (conv == (iconv_t)-1) {
cli_warnmsg("cli_codepage_to_utf8: Failed to open iconv.\n");
goto done;
// Try again w/out the //TRANSLIT, required because musl doesn't supprot it.
// See: https://github.com/akrennmair/newsbeuter/issues/364#issuecomment-250208235
conv = iconv_open("UTF-8", encoding);
if (conv == (iconv_t)-1) {
cli_warnmsg("cli_codepage_to_utf8: Failed to open iconv.\n");
goto done;
}
}
iconvRet = iconv(conv, &inbuf, &inbufsize, &out_utf8_index, &outbytesleft);

Loading…
Cancel
Save