From 30679d79994bc4957ea4b43187eeb90c6097f2db Mon Sep 17 00:00:00 2001 From: lda Date: Sun, 26 Nov 2023 13:35:12 +0100 Subject: [PATCH] [MOD] Make the User API use a bit of the parser --- src/User.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/User.c b/src/User.c index 9e36239..0f0f892 100644 --- a/src/User.c +++ b/src/User.c @@ -31,6 +31,8 @@ #include #include +#include + #include struct User @@ -907,26 +909,29 @@ UserIdParse(char *id, char *defaultServer) /* Fully-qualified user ID */ if (*id == '@') { - char *localStart = id + 1; - char *serverStart = localStart; - - while (*serverStart != ':' && *serverStart != '\0') - { - serverStart++; - } - - if (*serverStart == '\0') + CommonID commonID; + commonID.sigil = '\0'; + commonID.local = NULL; + commonID.server = NULL; + if (!ParseCommonID(id, &commonID) || !commonID.server) { Free(userId); + Free(commonID.local); + Free(commonID.server); + userId = NULL; + goto finish; + } + if (*commonID.server == '\0') + { + Free(userId); + Free(commonID.local); + Free(commonID.server); userId = NULL; goto finish; } - *serverStart = '\0'; - serverStart++; - - userId->localpart = StrDuplicate(localStart); - userId->server = StrDuplicate(serverStart); + userId->localpart = commonID.local; + userId->server = commonID.server; } else {