Changeset b7bc432 in code for icb.c


Ignore:
Timestamp:
Mar 4, 2014, 11:17:15 PM (11 years ago)
Author:
Stuart Henderson <stu@…>
Branches:
master
Children:
efa8586
Parents:
626f420
Message:

permit whitespace in topic, otherwise sanitize to _

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icb.c

    r626f420 rb7bc432  
    2525#include <ctype.h>
    2626#include <event.h>
     27#include <vis.h>
    2728
    2829#include "icb.h"
     
    150151
    151152        if (!nick || strlen(nick) == 0 ||
    152             icb_vis(is->nick, nick, ICB_MAXNICKLEN)) {
     153            icb_vis(is->nick, nick, ICB_MAXNICKLEN, VIS_SP)) {
    153154                icb_error(is, "Invalid nick");
    154155                icb_drop(is, NULL);
     
    158159                strlcpy(group, defgrp, ICB_MAXGRPLEN);
    159160        else
    160                 icb_vis(group, grp, ICB_MAXNICKLEN);
     161                icb_vis(group, grp, ICB_MAXNICKLEN, VIS_SP);
    161162        LIST_FOREACH(ig, &groups, entry) {
    162163                if (strcmp(ig->name, group) == 0)
     
    186187
    187188        if (client && strlen(client) > 0)
    188                 icb_vis(is->client, client, sizeof is->client);
     189                icb_vis(is->client, client, sizeof is->client, VIS_SP);
    189190        strlcpy(is->nick, nick, sizeof is->nick);
    190191        is->group = ig;
     
    251252        char whom[ICB_MAXNICKLEN];
    252253
    253         icb_vis(whom, to, ICB_MAXNICKLEN);
     254        icb_vis(whom, to, ICB_MAXNICKLEN, VIS_SP);
    254255
    255256        LIST_FOREACH(s, &ig->sess, entry) {
     
    273274        char command[32]; /* XXX */
    274275
    275         icb_vis(command, cmd, sizeof command);
     276        icb_vis(command, cmd, sizeof command, VIS_SP);
    276277
    277278        if ((handler = icb_cmd_lookup(command)) == NULL) {
     
    614615 */
    615616int
    616 icb_vis(char *dst, const char *src, size_t dstsize)
     617icb_vis(char *dst, const char *src, size_t dstsize, int flags)
    617618{
    618619        int si = 0, di = 0, td;
     
    621622                if (src[si] == '%')
    622623                        dst[di++] = '%', dst[di] = '%';
    623                 else if (isgraph(src[si]))
     624                else if (src[si] == ' ' && flags & VIS_SP)
     625                        dst[di] = '_';
     626                else if (isgraph(src[si]) || src[si] == ' ')
    624627                        dst[di] = src[si];
    625628                else {
Note: See TracChangeset for help on using the changeset viewer.