Skip to content

Commit

Permalink
Convert incoming partyline traffic to UTF-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
thommey committed Nov 13, 2016
1 parent 46c5214 commit 9b14f6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dcc.c
Expand Up @@ -978,14 +978,20 @@ static void eof_dcc_chat(int idx)
static void dcc_chat(int idx, char *buf, int i)
{
int nathan = 0, doron = 0, fixed = 0;
char *v, *d, filtbuf[2048];
char *v, *d, filtbuf[2048], encbuf[2048];
size_t encbufsize;

if (dcc[idx].status & STAT_TELNET)
strip_telnet(dcc[idx].sock, buf, &i);
if (buf[0] && (buf[0] != '.') &&
detect_dcc_flood(&dcc[idx].timeval, dcc[idx].u.chat, idx))
return;
dcc[idx].timeval = now;

encbufsize = convert_in_encoding(buf, strlen(buf), encbuf, sizeof encbuf - 1);
encbuf[sizeof encbuf - 1 - encbufsize] = '\0';
buf = encbuf;

if (buf[0]) {
const char *filt = check_tcl_filt(idx, buf);
if (filt != buf) {
Expand Down
4 changes: 4 additions & 0 deletions src/tcl.c
Expand Up @@ -151,6 +151,10 @@ static void reopen_encoding(iconv_t *conv, char *from, char *to)
putlog(LOG_MISC, "*", "Warning: Unable to load '%s' -> '%s' encoding. Use `iconv -l` to see valid encoding names.", from, to);
}

/* Convert encoding according to convertion from
* string in src with length len into dst buffer with size dstlen.
* Returns the remaining space left in dst.
*/
static size_t convert_encoding(iconv_t conversion, char *src, size_t len, char *dst, size_t dstlen)
{
size_t i;
Expand Down

0 comments on commit 9b14f6c

Please sign in to comment.