From 9dcba2758b75868b8837141b9cea403bc0c1b756 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 Apr 2020 20:11:22 +1000 Subject: Fix up name validation. --- src/sledjchisl/sledjchisl.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 771cf87..f21b2a6 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -3808,7 +3808,7 @@ static int nameValidate(reqData *Rd, inputForm *iF, inputValue *iV) } else { - int l0 = strlen(name), l1; + int l0 = strlen(name), l1 = 0, l2 = 0; if (0 == l0) { @@ -3825,11 +3825,17 @@ static int nameValidate(reqData *Rd, inputForm *iF, inputValue *iV) if (isalnum(name[i]) == 0) { - if ((' ' == name[i] && (NULL == s))) + if ((' ' == name[i] /*&& (NULL == s)*/)) { s = &name[i]; *s++ = '\0'; - l1 = strlen(s); + while(' ' == *s) + { + i++; + s++; + } + l1 = strlen(name); + l2 = strlen(s); // Apparently names are not case sensitive on login, but stored with case in the database. // I confirmed that, can log in no matter what case you use. @@ -3842,16 +3848,6 @@ static int nameValidate(reqData *Rd, inputForm *iF, inputValue *iV) // Singularity at least limits the total name to 64. // I can't find any limitations on characters allowed, but I only ever see letters and digits used. Case is stored, but not significant. // OpenSims "create user" console command doesn't sanitize it at all, even crashing on some names. - if (0 == l1) - { - bitch(Rd, "Account names have to be two words.", ""); - ret++; - } - if ((31 < i) || (31 < l1)) - { - bitch(Rd, "First and last names are limited to 31 letters each.", ""); - ret++; - } } else { @@ -3863,16 +3859,29 @@ static int nameValidate(reqData *Rd, inputForm *iF, inputValue *iV) } } + if (NULL == s) + { + bitch(Rd, "Account names have to be two words.", ""); + ret++; + } + if ((31 < l1) || (31 < l2)) + { + bitch(Rd, "First and last names are limited to 31 letters each.", ""); + ret++; + } + if ((0 == l1) || (0 == l2)) + { + bitch(Rd, "First and last names have to be more than one letter each.", ""); + ret++; + } + if (0 == ret) { Rd->stuff->putstr(Rd->stuff, "firstName", name); Rd->stuff->putstr(Rd->stuff, "lastName", s); - if (s) {s--; *s = ' '; s++;} - s = NULL; - Rd->stuff->putstr(Rd->stuff, "name", name); - Rd->shs.name = xstrdup(name); + Rd->stuff->putstrf(Rd->stuff, "name", "%s %s", name, s); + Rd->shs.name = Rd->stuff->getstr(Rd->stuff, "name", true); } - if (s) {s--; *s = ' '; s++;} } } free(name); -- cgit v1.1