From: Roger Dingledine Date: Wed, 1 Oct 2008 03:41:33 +0000 (+0000) Subject: Now NodeFamily and MyFamily config options allow spaces in X-Git-Tag: tor-0.2.1.7-alpha~70 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7af43a62497fb3e10c8de9a5bb8cc8113efb99c;p=thirdparty%2Ftor.git Now NodeFamily and MyFamily config options allow spaces in identity fingerprints, so it's easier to paste them in. Suggested by Lucky Green. svn:r17021 --- diff --git a/ChangeLog b/ChangeLog index b48463dbf1..ff7a0e02f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Changes in version 0.2.1.7-alpha - 2008-10-xx + o Minor features: + - Now NodeFamily and MyFamily config options allow spaces in + identity fingerprints, so it's easier to paste them in. + Suggested by Lucky Green. + + Changes in version 0.2.1.6-alpha - 2008-09-30 o Major features: - Implement proposal 121: make it possible to build hidden services diff --git a/src/common/container.c b/src/common/container.c index 8021bd19c3..060615d1c3 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -324,12 +324,17 @@ smartlist_insert(smartlist_t *sl, int idx, void *val) /** * Split a string str along all occurrences of sep, - * adding the split strings, in order, to sl. If - * flags&SPLIT_SKIP_SPACE is true, remove initial and - * trailing space from each entry. If - * flags&SPLIT_IGNORE_BLANK is true, remove any entries of - * length 0. If max>0, divide the string into no more than max - * pieces. If sep is NULL, split on any sequence of horizontal space. + * adding the split strings, in order, to sl. + * + * If flags&SPLIT_SKIP_SPACE is true, remove initial and + * trailing space from each entry. + * If flags&SPLIT_IGNORE_BLANK is true, remove any entries + * of length 0. + * If flags&SPLIT_STRIP_SPACE is true, strip spaces from each + * split string. + * + * If max>0, divide the string into no more than max pieces. If + * sep is NULL, split on any sequence of horizontal space. */ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, @@ -375,7 +380,10 @@ smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, --end; } if (end != cp || !(flags&SPLIT_IGNORE_BLANK)) { - smartlist_add(sl, tor_strndup(cp, end-cp)); + char *string = tor_strndup(cp, end-cp); + if (flags&SPLIT_STRIP_SPACE) + tor_strstrip(string, " "); + smartlist_add(sl, string); ++n; } if (!next) diff --git a/src/common/container.h b/src/common/container.h index 0a790ea4ac..b4ca358289 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -121,6 +121,7 @@ void smartlist_pqueue_assert_ok(smartlist_t *sl, #define SPLIT_SKIP_SPACE 0x01 #define SPLIT_IGNORE_BLANK 0x02 +#define SPLIT_STRIP_SPACE 0x04 int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max); char *smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, diff --git a/src/or/config.c b/src/or/config.c index c288e7f803..d21e248d10 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3740,7 +3740,7 @@ get_default_conf_file(void) #endif } -/** Verify whether lst is a string containing valid-looking space-separated +/** Verify whether lst is a string containing valid-looking comma-separated * nicknames, or NULL. Return 0 on success. Warn and return -1 on failure. */ static int @@ -3752,7 +3752,10 @@ check_nickname_list(const char *lst, const char *name, char **msg) if (!lst) return 0; sl = smartlist_create(); - smartlist_split_string(sl, lst, ",", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); + + smartlist_split_string(sl, lst, ",", + SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK|SPLIT_STRIP_SPACE, 0); + SMARTLIST_FOREACH(sl, const char *, s, { if (!is_legal_nickname_or_hexdigest(s)) { diff --git a/src/or/router.c b/src/or/router.c index 29b930bbc0..c3dc9867de 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1313,7 +1313,7 @@ router_rebuild_descriptor(int force) family = smartlist_create(); ri->declared_family = smartlist_create(); smartlist_split_string(family, options->MyFamily, ",", - SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); + SPLIT_SKIP_SPACE|SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); SMARTLIST_FOREACH(family, char *, name, { routerinfo_t *member; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index be38cc569e..4ea307d91a 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1324,7 +1324,7 @@ router_nickname_is_in_list(routerinfo_t *router, const char *list) nickname_list = smartlist_create(); smartlist_split_string(nickname_list, list, ",", - SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); + SPLIT_SKIP_SPACE|SPLIT_STRIP_SPACE|SPLIT_IGNORE_BLANK, 0); SMARTLIST_FOREACH(nickname_list, const char *, cp, if (router_nickname_matches(router, cp)) {v=1;break;}); SMARTLIST_FOREACH(nickname_list, char *, cp, tor_free(cp));