Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -94,19 +94,19 @@ { OFString *old = username; char *node; Stringprep_rc rc; - if ((rc = stringprep_profile([username_ cString], &node, + if ((rc = stringprep_profile([username_ UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self profile: @"SASLprep" string: username_]; @try { - username = [[OFString alloc] initWithCString: node]; + username = [[OFString alloc] initWithUTF8String: node]; } @finally { free(node); } [old release]; @@ -121,20 +121,20 @@ { OFString *old = resource; char *res; Stringprep_rc rc; - if ((rc = stringprep_profile([resource_ cString], &res, + if ((rc = stringprep_profile([resource_ UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self profile: @"Resourceprep" string: resource_]; @try { - resource = [[OFString alloc] initWithCString: res]; + resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } [old release]; @@ -149,20 +149,20 @@ { OFString *old = server; char *srv; Idna_rc rc; - if ((rc = idna_to_ascii_8z([server_ cString], + if ((rc = idna_to_ascii_8z([server_ UTF8String], &srv, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException newWithClass: isa connection: self operation: @"ToASCII" string: server_]; @try { - server = [[OFString alloc] initWithCString: srv]; + server = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } [old release]; @@ -177,19 +177,19 @@ { OFString *old = domain; char *srv; Stringprep_rc rc; - if ((rc = stringprep_profile([domain_ cString], &srv, + if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self profile: @"Nameprep" string: domain_]; @try { - domain = [[OFString alloc] initWithCString: srv]; + domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } [old release]; @@ -204,19 +204,19 @@ { OFString *old = password; char *pass; Stringprep_rc rc; - if ((rc = stringprep_profile([password_ cString], &pass, + if ((rc = stringprep_profile([password_ UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self profile: @"SASLprep" string: password_]; @try { - password = [[OFString alloc] initWithCString: pass]; + password = [[OFString alloc] initWithUTF8String: pass]; } @finally { free(pass); } [old release]; @@ -239,21 +239,21 @@ if (server) [sock connectToHost: server port: port]; else { - if ((rc = idna_to_ascii_8z([domain cString], &cDomainToASCII, + if ((rc = idna_to_ascii_8z([domain UTF8String], &cDomainToASCII, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException newWithClass: isa connection: self operation: @"ToASCII" string: domain]; @try { domainToASCII = [OFString - stringWithCString: cDomainToASCII]; + stringWithUTF8String: cDomainToASCII]; } @finally { free(cDomainToASCII); } @try { Index: src/XMPPJID.m ================================================================== --- src/XMPPJID.m +++ src/XMPPJID.m @@ -108,19 +108,19 @@ [old release]; node = nil; return; } - if ((rc = stringprep_profile([node_ cString], &nodepart, + if ((rc = stringprep_profile([node_ UTF8String], &nodepart, "Nodeprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: nil profile: @"Nodeprep" string: node_]; @try { - node = [[OFString alloc] initWithCString: nodepart]; + node = [[OFString alloc] initWithUTF8String: nodepart]; } @finally { free(nodepart); } [old release]; @@ -135,19 +135,19 @@ { OFString *old = domain; char *srv; Stringprep_rc rc; - if ((rc = stringprep_profile([domain_ cString], &srv, + if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: nil profile: @"Nameprep" string: domain_]; @try { - domain = [[OFString alloc] initWithCString: srv]; + domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } [old release]; @@ -168,20 +168,20 @@ [old release]; resource = nil; return; } - if ((rc = stringprep_profile([resource_ cString], &res, + if ((rc = stringprep_profile([resource_ UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: nil profile: @"Resourceprep" string: resource_]; @try { - resource = [[OFString alloc] initWithCString: res]; + resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } [old release]; Index: src/XMPPPLAINAuth.m ================================================================== --- src/XMPPPLAINAuth.m +++ src/XMPPPLAINAuth.m @@ -54,19 +54,19 @@ /* separator */ [message addItem: ""]; /* authcid */ - [message addNItems: [authcid cStringLength] - fromCArray: [authcid cString]]; + [message addNItems: [authcid UTF8StringLength] + fromCArray: [authcid UTF8String]]; /* separator */ [message addItem: ""]; /* passwd */ - [message addNItems: [password cStringLength] - fromCArray: [password cString]]; + [message addNItems: [password UTF8StringLength] + fromCArray: [password UTF8String]]; return message; } - (OFDataArray*)calculateResponseWithChallenge: (OFDataArray*)challenge Index: src/XMPPSCRAMAuth.m ================================================================== --- src/XMPPSCRAMAuth.m +++ src/XMPPSCRAMAuth.m @@ -166,15 +166,15 @@ clientFirstMessageBare = nil; clientFirstMessageBare = [[OFString alloc] initWithFormat: @"n=%@,r=%@", authcid, cNonce]; - [ret addNItems: [GS2Header cStringLength] - fromCArray: [GS2Header cString]]; + [ret addNItems: [GS2Header UTF8StringLength] + fromCArray: [GS2Header UTF8String]]; - [ret addNItems: [clientFirstMessageBare cStringLength] - fromCArray: [clientFirstMessageBare cString]]; + [ret addNItems: [clientFirstMessageBare UTF8StringLength] + fromCArray: [clientFirstMessageBare UTF8String]]; return ret; } - (OFDataArray*)calculateResponseWithChallenge: (OFDataArray*)challenge @@ -196,13 +196,13 @@ hash = [[[hashType alloc] init] autorelease]; ret = [OFDataArray dataArrayWithItemSize: 1]; authMessage = [OFDataArray dataArrayWithItemSize: 1]; - OFString *chal = [OFString stringWithCString: [challenge cArray] - length: [challenge count] * - [challenge itemSize]]; + OFString *chal = [OFString stringWithUTF8String: [challenge cArray] + length: [challenge count] * + [challenge itemSize]]; enumerator = [[chal componentsSeparatedByString: @","] objectEnumerator]; while ((comp = [enumerator nextObject]) != nil) { OFString *entry = [comp substringWithRange: @@ -230,34 +230,34 @@ if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT)) @throw [OFInvalidServerReplyException newWithClass: isa]; // Add c= tmpArray = [OFDataArray dataArrayWithItemSize: 1]; - [tmpArray addNItems: [GS2Header cStringLength] - fromCArray: [GS2Header cString]]; + [tmpArray addNItems: [GS2Header UTF8StringLength] + fromCArray: [GS2Header UTF8String]]; if (plusAvailable && [connection encrypted]) { OFDataArray *channelBinding = [((SSLSocket*)[connection socket]) channelBindingDataWithType: @"tls-unique"]; [tmpArray addNItems: [channelBinding count] fromCArray: [channelBinding cArray]]; } tmpString = [tmpArray stringByBase64Encoding]; [ret addNItems: 2 fromCArray: "c="]; - [ret addNItems: [tmpString cStringLength] - fromCArray: [tmpString cString]]; + [ret addNItems: [tmpString UTF8StringLength] + fromCArray: [tmpString UTF8String]]; // Add r= [ret addItem: ","]; [ret addNItems: 2 fromCArray: "r="]; - [ret addNItems: [sNonce cStringLength] - fromCArray: [sNonce cString]]; + [ret addNItems: [sNonce UTF8StringLength] + fromCArray: [sNonce UTF8String]]; tmpArray = [OFDataArray dataArrayWithItemSize: 1]; - [tmpArray addNItems: [password cStringLength] - fromCArray: [password cString]]; + [tmpArray addNItems: [password UTF8StringLength] + fromCArray: [password UTF8String]]; /* * IETF RFC 5802: * SaltedPassword := Hi(Normalize(password), salt, i) */ @@ -269,12 +269,12 @@ * IETF RFC 5802: * AuthMessage := client-first-message-bare + "," + * server-first-message + "," + * client-final-message-without-proof */ - [authMessage addNItems: [clientFirstMessageBare cStringLength] - fromCArray: [clientFirstMessageBare cString]]; + [authMessage addNItems: [clientFirstMessageBare UTF8StringLength] + fromCArray: [clientFirstMessageBare UTF8String]]; [authMessage addItem: ","]; [authMessage addNItems: [challenge count] * [challenge itemSize] fromCArray: [challenge cArray]]; [authMessage addItem: ","]; [authMessage addNItems: [ret count] @@ -342,12 +342,12 @@ // Add p= [ret addItem: ","]; [ret addNItems: 2 fromCArray: "p="]; tmpString = [tmpArray stringByBase64Encoding]; - [ret addNItems: [tmpString cStringLength] - fromCArray: [tmpString cString]]; + [ret addNItems: [tmpString UTF8StringLength] + fromCArray: [tmpString UTF8String]]; [ret retain]; [pool release]; return [ret autorelease]; @@ -354,13 +354,13 @@ } - (void)parseServerFinalMessage: (OFDataArray*)message { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFString *mess = [OFString stringWithCString: [message cArray] - length: [message count] * - [message itemSize]]; + OFString *mess = [OFString stringWithUTF8String: [message cArray] + length: [message count] * + [message itemSize]]; OFString *value = [mess substringWithRange: of_range(2, [mess length] - 2)]; if ([mess hasPrefix: @"v="]) { if (![value isEqual: [serverSignature stringByBase64Encoding]]) @@ -391,10 +391,11 @@ buf[i] = tmp; } return [OFString stringWithCString: (char*)buf + encoding: OF_STRING_ENCODING_ASCII length: 64]; } - (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key data: (OFDataArray*)data Index: src/XMPPSRVLookup.m ================================================================== --- src/XMPPSRVLookup.m +++ src/XMPPSRVLookup.m @@ -100,11 +100,13 @@ if (dn_expand(ns_msg_base(handle), ns_msg_end(handle), (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1) @throw [OFInitializationFailedException newWithClass: isa]; - target = [[OFString alloc] initWithCString: buffer]; + target = [[OFString alloc] + initWithCString: buffer + encoding: OF_STRING_ENCODING_NATIVE]; } @catch (id e) { [self release]; @throw e; } @@ -211,12 +213,13 @@ newWithClass: isa socket: nil host: domain]; answer = [self allocMemoryWithSize: of_pagesize]; - answerLen = res_nsearch(&resState, [request cString], ns_c_in, - ns_t_srv, answer, (int)of_pagesize); + answerLen = res_nsearch(&resState, [request cStringWithEncoding: + OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer, + (int)of_pagesize); if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) || (h_errno == NO_DATA))) return;