Changeset b7bc432 in code


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 _

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cmd.c

    r626f420 rb7bc432  
    8787        }
    8888
    89         icb_vis(whom, arg, ICB_MAXNICKLEN);
     89        icb_vis(whom, arg, ICB_MAXNICKLEN, VIS_SP);
    9090
    9191        LIST_FOREACH(s, &ig->sess, entry) {
     
    129129        }
    130130
    131         icb_vis(whom, arg, ICB_MAXNICKLEN);
     131        icb_vis(whom, arg, ICB_MAXNICKLEN, VIS_SP);
    132132
    133133        /* who would be a target then? */
     
    160160        }
    161161
    162         icb_vis(group, arg, ICB_MAXGRPLEN);
     162        icb_vis(group, arg, ICB_MAXGRPLEN, VIS_SP);
    163163
    164164        LIST_FOREACH(ig, &groups, entry) {
     
    237237        if (strlen(arg) > ICB_MAXNICKLEN)
    238238                arg[ICB_MAXNICKLEN - 1] = '\0';
    239         icb_vis(nick, arg, ICB_MAXNICKLEN);
     239        icb_vis(nick, arg, ICB_MAXNICKLEN, VIS_SP);
    240240        LIST_FOREACH(s, &ig->sess, entry) {
    241241                if (strcmp(s->nick, nick) == 0) {
     
    312312                        return;
    313313                }
    314                 icb_vis(whom, arg, ICB_MAXNICKLEN);
     314                icb_vis(whom, arg, ICB_MAXNICKLEN, VIS_SP);
    315315                LIST_FOREACH(s, &ig->sess, entry) {
    316316                        if (strcmp(s->nick, whom) == 0)
     
    344344                        return;
    345345                }
    346                 icb_vis(topic, arg, ICB_MAXTOPICLEN);
     346                icb_vis(topic, arg, ICB_MAXTOPICLEN, 0);
    347347                strlcpy(ig->topic, topic, sizeof ig->topic);
    348348                icb_status_group(ig, NULL, STATUS_TOPIC,
     
    360360                return icb_who(is, NULL);
    361361
    362         icb_vis(group, arg, ICB_MAXGRPLEN);
     362        icb_vis(group, arg, ICB_MAXGRPLEN, VIS_SP);
    363363        LIST_FOREACH(ig, &groups, entry) {
    364364                if (strcmp(ig->name, group) == 0)
  • 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 {
  • icb.h

    r626f420 rb7bc432  
    139139                    int, const char *, ...);
    140140void             icb_who(struct icb_session *, struct icb_group *);
    141 int              icb_vis(char *, const char *, size_t);
     141int              icb_vis(char *, const char *, size_t, int);
    142142
    143143/* callbacks from icbd.c */
Note: See TracChangeset for help on using the changeset viewer.