From 0e200d99d72c4693c9be8dce771273581c956d61 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Fri, 11 Feb 2011 02:25:15 +0100 Subject: [PATCH] Respectively do Nameprep/SASLPrep on domain name and password --- src/XMPPConnection.m | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index c09cfb3..901adec 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -66,6 +66,48 @@ [old release]; } +- (void)setServer: (OFString*)server_ +{ + OFString *old = server; + char *srv; + + Stringprep_rc rc; + if ((rc = stringprep_profile([server_ cString], &srv, "Nameprep", 0)) + != STRINGPREP_OK) { + of_log(@"Nameprep failed: %s", stringprep_strerror(rc)); + assert(0); + } + + @try { + server = [[OFString alloc] initWithCString: srv]; + } @finally { + free(srv); + } + + [old release]; +} + +- (void)setPassword: (OFString*)password_ +{ + OFString *old = password; + char *pass; + + Stringprep_rc rc; + if ((rc = stringprep_profile([password_ cString], &pass, "SASLprep", 0)) + != STRINGPREP_OK) { + of_log(@"SASLprep failed: %s", stringprep_strerror(rc)); + assert(0); + } + + @try { + password = [[OFString alloc] initWithCString: pass]; + } @finally { + free(pass); + } + + [old release]; +} + - (void)_startStream { [sock writeFormat: @"\n"