From e4f7e4b35fb4ce2221b175fe1b19d7af06d2a7d2 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Tue, 15 Feb 2011 03:52:16 +0100 Subject: [PATCH] Perform SASLPrep on the username and Resourceprep on the resource The username is not necessarily a nodepart, therefore SASLPrep is more appropriate than Nodeprep which we had before. --- src/XMPPConnection.m | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index fd5e23d..de3a5d5 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -52,9 +52,9 @@ char *node; Stringprep_rc rc; - if ((rc = stringprep_profile([username_ cString], &node, "Nodeprep", 0)) + if ((rc = stringprep_profile([username_ cString], &node, "SASLprep", 0)) != STRINGPREP_OK) { - of_log(@"Nodeprep failed: %s", stringprep_strerror(rc)); + of_log(@"SASLprep failed: %s", stringprep_strerror(rc)); assert(0); } @@ -67,6 +67,27 @@ [old release]; } +- (void)setResource: (OFString*)resource_ +{ + OFString *old = resource; + char *res; + + Stringprep_rc rc; + if ((rc = stringprep_profile([resource_ cString], &res, "Resourceprep", 0)) + != STRINGPREP_OK) { + of_log(@"Resourceprep failed: %s", stringprep_strerror(rc)); + assert(0); + } + + @try { + resource = [[OFString alloc] initWithCString: res]; + } @finally { + free(res); + } + + [old release]; +} + - (void)setServer: (OFString*)server_ { OFString *old = server;