ObjXMPP  Check-in [c987aa9a5f]

Overview
Comment:Don't access isa directly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c987aa9a5fc0a6bfbc976f57a2ba39a0cd58be4f4c4b37b6ddc25553458dd1c7
User & Date: js on 2012-07-12 03:34:20
Other Links: manifest | tags
Context
2012-08-10
12:08
Close the stream when restricted XML is received check-in: f848b17360 user: js tags: trunk
2012-07-12
03:34
Don't access isa directly. check-in: c987aa9a5f user: js tags: trunk
2012-06-07
12:19
Adjust to latest ObjFW API changes. check-in: 6a3b21ce25 user: js tags: trunk
Changes

Modified src/XMPPConnection.m from [e2f332ead2] to [eb7dbdc3cf].

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	OFString *old = username;
	char *node;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([username_ UTF8String], &node,
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"SASLprep"
				string: username_];

	@try {
		username = [[OFString alloc] initWithUTF8String: node];
	} @finally {







|







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	OFString *old = username;
	char *node;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([username_ UTF8String], &node,
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: self
			       profile: @"SASLprep"
				string: username_];

	@try {
		username = [[OFString alloc] initWithUTF8String: node];
	} @finally {
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
	OFString *old = resource;
	char *res;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([resource_ UTF8String], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"Resourceprep"
				string: resource_];

	@try {
		resource = [[OFString alloc] initWithUTF8String: res];
	} @finally {







|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
	OFString *old = resource;
	char *res;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([resource_ UTF8String], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: self
			       profile: @"Resourceprep"
				string: resource_];

	@try {
		resource = [[OFString alloc] initWithUTF8String: res];
	} @finally {
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
	OFString *oldDomainToASCII = domainToASCII;
	char *srv;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([domain_ UTF8String], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"Nameprep"
				string: domain_];

	@try {
		domain = [[OFString alloc] initWithUTF8String: srv];
	} @finally {







|







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
	OFString *oldDomainToASCII = domainToASCII;
	char *srv;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([domain_ UTF8String], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: self
			       profile: @"Nameprep"
				string: domain_];

	@try {
		domain = [[OFString alloc] initWithUTF8String: srv];
	} @finally {
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
	OFString *old = password;
	char *pass;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([password_ UTF8String], &pass,
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"SASLprep"
				string: password_];

	@try {
		password = [[OFString alloc] initWithUTF8String: pass];
	} @finally {







|







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
	OFString *old = password;
	char *pass;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([password_ UTF8String], &pass,
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: self
			       profile: @"SASLprep"
				string: password_];

	@try {
		password = [[OFString alloc] initWithUTF8String: pass];
	} @finally {
691
692
693
694
695
696
697
698

699
700
701
702
703
704
705
706
707
708
		else
			condition = @"undefined";

		reason = [[element
		    elementForName: @"text"
			 namespace: XMPP_NS_XMPP_STREAM] stringValue];

		@throw [XMPPStreamErrorException exceptionWithClass: isa

							 connection: self
							  condition: condition
							     reason: reason];
		return;
	}

	assert(0);
}

- (void)XMPP_handleTLS: (OFXMLElement*)element







|
>
|
|
|







691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
		else
			condition = @"undefined";

		reason = [[element
		    elementForName: @"text"
			 namespace: XMPP_NS_XMPP_STREAM] stringValue];

		@throw [XMPPStreamErrorException
		    exceptionWithClass: [self class]
			    connection: self
			     condition: condition
				reason: reason];
		return;
	}

	assert(0);
}

- (void)XMPP_handleTLS: (OFXMLElement*)element
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
		[self XMPP_startStream];

		return;
	}

	if ([[element name] isEqual: @"failure"])
		/* TODO: Find/create an exception to throw here */
		@throw [OFException exceptionWithClass: isa];

	assert(0);
}

- (void)XMPP_handleSASL: (OFXMLElement*)element
{
	if ([[element name] isEqual: @"challenge"]) {







|







732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
		[self XMPP_startStream];

		return;
	}

	if ([[element name] isEqual: @"failure"])
		/* TODO: Find/create an exception to throw here */
		@throw [OFException exceptionWithClass: [self class]];

	assert(0);
}

- (void)XMPP_handleSASL: (OFXMLElement*)element
{
	if ([[element name] isEqual: @"challenge"]) {
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
		return;
	}

	if ([[element name] isEqual: @"failure"]) {
		of_log(@"Auth failed!");
		// FIXME: Do more parsing/handling
		@throw [XMPPAuthFailedException
		    exceptionWithClass: isa
			    connection: self
				reason: [element XMLString]];
	}

	assert(0);
}








|







778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
		return;
	}

	if ([[element name] isEqual: @"failure"]) {
		of_log(@"Auth failed!");
		// FIXME: Do more parsing/handling
		@throw [XMPPAuthFailedException
		    exceptionWithClass: [self class]
			    connection: self
				reason: [element XMLString]];
	}

	assert(0);
}

844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
		    [OFXMLElement elementWithName: @"starttls"
					namespace: XMPP_NS_STARTTLS]];
		return;
	}

	if (encryptionRequired && !encrypted)
		/* TODO: Find/create an exception to throw here */
		@throw [OFException exceptionWithClass: isa];

	if ([element elementForName: @"ver"
			  namespace: XMPP_NS_ROSTERVER] != nil)
		supportsRosterVersioning = YES;

	if (mechs != nil) {
		OFEnumerator *enumerator;







|







845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
		    [OFXMLElement elementWithName: @"starttls"
					namespace: XMPP_NS_STARTTLS]];
		return;
	}

	if (encryptionRequired && !encrypted)
		/* TODO: Find/create an exception to throw here */
		@throw [OFException exceptionWithClass: [self class]];

	if ([element elementForName: @"ver"
			  namespace: XMPP_NS_ROSTERVER] != nil)
		supportsRosterVersioning = YES;

	if (mechs != nil) {
		OFEnumerator *enumerator;
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
	OFString *ret;
	char *cDomain;
	Idna_rc rc;

	if ((rc = idna_to_ascii_8z([domain_ UTF8String],
	    &cDomain, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS)
		@throw [XMPPIDNATranslationFailedException
		    exceptionWithClass: isa
			    connection: self
			     operation: @"ToASCII"
				string: domain_];

	@try {
		ret = [[OFString alloc] initWithUTF8String: cDomain];
	} @finally {







|







1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
	OFString *ret;
	char *cDomain;
	Idna_rc rc;

	if ((rc = idna_to_ascii_8z([domain_ UTF8String],
	    &cDomain, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS)
		@throw [XMPPIDNATranslationFailedException
		    exceptionWithClass: [self class]
			    connection: self
			     operation: @"ToASCII"
				string: domain_];

	@try {
		ret = [[OFString alloc] initWithUTF8String: cDomain];
	} @finally {
1066
1067
1068
1069
1070
1071
1072
1073

1074
1075
1076
1077
1078
1079
1080
{
	return port;
}

- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
{
	if (streamOpen)
		@throw [OFInvalidArgumentException exceptionWithClass: isa];


	dataStorage = dataStorage_;
}

- (id <XMPPStorage>)dataStorage
{
	return dataStorage;







|
>







1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
{
	return port;
}

- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
{
	if (streamOpen)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	dataStorage = dataStorage_;
}

- (id <XMPPStorage>)dataStorage
{
	return dataStorage;

Modified src/XMPPExceptions.m from [9ce07a194d] to [8255027a48].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
	return [[[self alloc] initWithClass: class_
				 connection: conn] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn







|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
	return [[[self alloc] initWithClass: class_
				 connection: conn] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
				  condition: condition_
				     reason: reason_] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn







|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
				  condition: condition_
				     reason: reason_] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
				    profile: profile
				     string: string] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn







|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
				    profile: profile
				     string: string] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
				  operation: operation
				     string: string] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn







|







234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
				  operation: operation
				     string: string] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
				 connection: conn
				     reason: reason_] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn







|







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
				 connection: conn
				     reason: reason_] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn

Modified src/XMPPIQ.m from [ce10766ebf] to [951ee83820].

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
			      type: type_
				ID: ID_];

	@try {
		if (![type_ isEqual: @"get"] && ![type_ isEqual: @"set"] &&
		    ![type_ isEqual: @"result"] && ![type_ isEqual: @"error"])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
			      type: type_
				ID: ID_];

	@try {
		if (![type_ isEqual: @"get"] && ![type_ isEqual: @"set"] &&
		    ![type_ isEqual: @"result"] && ![type_ isEqual: @"error"])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;

Modified src/XMPPJID.m from [664ab370cc] to [1a9c48ba03].

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
		return;
	}

	if (((rc = stringprep_profile([node_ UTF8String], &nodepart,
	    "Nodeprep", 0)) != STRINGPREP_OK) || (nodepart[0] == '\0') ||
	    (strlen(nodepart) > 1023))
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: nil
			       profile: @"Nodeprep"
				string: node_];

	@try {
		node = [[OFString alloc] initWithUTF8String: nodepart];
	} @finally {







|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
		return;
	}

	if (((rc = stringprep_profile([node_ UTF8String], &nodepart,
	    "Nodeprep", 0)) != STRINGPREP_OK) || (nodepart[0] == '\0') ||
	    (strlen(nodepart) > 1023))
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: nil
			       profile: @"Nodeprep"
				string: node_];

	@try {
		node = [[OFString alloc] initWithUTF8String: nodepart];
	} @finally {
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
	char *srv;
	Stringprep_rc rc;

	if (((rc = stringprep_profile([domain_ UTF8String], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') ||
	    (strlen(srv) > 1023))
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: nil
			       profile: @"Nameprep"
				string: domain_];

	@try {
		domain = [[OFString alloc] initWithUTF8String: srv];
	} @finally {







|







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
	char *srv;
	Stringprep_rc rc;

	if (((rc = stringprep_profile([domain_ UTF8String], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') ||
	    (strlen(srv) > 1023))
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: nil
			       profile: @"Nameprep"
				string: domain_];

	@try {
		domain = [[OFString alloc] initWithUTF8String: srv];
	} @finally {
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		return;
	}

	if (((rc = stringprep_profile([resource_ UTF8String], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK) || (res[0] == '\0') ||
	    (strlen(res) > 1023))
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: nil
			       profile: @"Resourceprep"
				string: resource_];

	@try {
		resource = [[OFString alloc] initWithUTF8String: res];
	} @finally {







|







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		return;
	}

	if (((rc = stringprep_profile([resource_ UTF8String], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK) || (res[0] == '\0') ||
	    (strlen(res) > 1023))
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: [self class]
			    connection: nil
			       profile: @"Resourceprep"
				string: resource_];

	@try {
		resource = [[OFString alloc] initWithUTF8String: res];
	} @finally {

Modified src/XMPPJSONFileStorage.m from [d1bdcd6ace] to [f859e69a55].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#import <ObjFW/OFNotImplementedException.h>

#import "XMPPJSONFileStorage.h"

@implementation XMPPJSONFileStorage
- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithFile: (OFString*)file_
{







|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#import <ObjFW/OFNotImplementedException.h>

#import "XMPPJSONFileStorage.h"

@implementation XMPPJSONFileStorage
- init
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithFile: (OFString*)file_
{

Modified src/XMPPRoster.m from [4b6f06492d] to [af0b58584d].

209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
{
	[delegates removeDelegate: delegate];
}

- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
{
	if (rosterRequested)
		@throw [OFInvalidArgumentException exceptionWithClass: isa];


	dataStorage = dataStorage_;
}

- (id <XMPPStorage>)dataStorage
{
	return dataStorage;







|
>







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
{
	[delegates removeDelegate: delegate];
}

- (void)setDataStorage: (id <XMPPStorage>)dataStorage_
{
	if (rosterRequested)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	dataStorage = dataStorage_;
}

- (id <XMPPStorage>)dataStorage
{
	return dataStorage;

Modified src/XMPPSCRAMAuth.m from [b45bfcda94] to [47e72febdc].

227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252

253
254
255
256
257
258
259
	while ((comp = [enumerator nextObject]) != nil) {
		OFString *entry = [comp substringWithRange:
		    of_range(2, [comp length] - 2)];

		if ([comp hasPrefix: @"r="]) {
			if (![entry hasPrefix: cNonce])
				@throw [XMPPAuthFailedException
				    exceptionWithClass: isa
					    connection: nil
						reason: @"Received wrong "
							@"nonce"];

			sNonce = entry;
			got |= GOT_SNONCE;
		} else if ([comp hasPrefix: @"s="]) {
			salt = [OFDataArray
			    dataArrayWithBase64EncodedString: entry];
			got |= GOT_SALT;
		} else if ([comp hasPrefix: @"i="]) {
			iterCount = [entry decimalValue];
			got |= GOT_ITERCOUNT;
		}
	}

	if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT))
		@throw [OFInvalidServerReplyException exceptionWithClass: isa];


	// Add c=<base64(GS2Header+channelBindingData)>
	tmpArray = [OFDataArray dataArray];
	[tmpArray addItemsFromCArray: [GS2Header UTF8String]
			       count: [GS2Header UTF8StringLength]];
	if (plusAvailable && [connection encrypted]) {
		OFDataArray *channelBinding = [((SSLSocket*)[connection socket])







|

















|
>







227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
	while ((comp = [enumerator nextObject]) != nil) {
		OFString *entry = [comp substringWithRange:
		    of_range(2, [comp length] - 2)];

		if ([comp hasPrefix: @"r="]) {
			if (![entry hasPrefix: cNonce])
				@throw [XMPPAuthFailedException
				    exceptionWithClass: [self class]
					    connection: nil
						reason: @"Received wrong "
							@"nonce"];

			sNonce = entry;
			got |= GOT_SNONCE;
		} else if ([comp hasPrefix: @"s="]) {
			salt = [OFDataArray
			    dataArrayWithBase64EncodedString: entry];
			got |= GOT_SALT;
		} else if ([comp hasPrefix: @"i="]) {
			iterCount = [entry decimalValue];
			got |= GOT_ITERCOUNT;
		}
	}

	if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT))
		@throw [OFInvalidServerReplyException
		    exceptionWithClass: [self class]];

	// Add c=<base64(GS2Header+channelBindingData)>
	tmpArray = [OFDataArray dataArray];
	[tmpArray addItemsFromCArray: [GS2Header UTF8String]
			       count: [GS2Header UTF8StringLength]];
	if (plusAvailable && [connection encrypted]) {
		OFDataArray *channelBinding = [((SSLSocket*)[connection socket])
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
				       length: [data count] *
					       [data itemSize]];
	value = [mess substringWithRange: of_range(2, [mess length] - 2)];

	if ([mess hasPrefix: @"v="]) {
		if (![value isEqual: [serverSignature stringByBase64Encoding]])
			@throw [XMPPAuthFailedException
			    exceptionWithClass: isa
				    connection: nil
					reason: @"Received wrong "
						@"ServerSignature"];
		authenticated = YES;
	} else
		@throw [XMPPAuthFailedException exceptionWithClass: isa
							connection: nil
							    reason: value];

	return nil;
}

- (OFString*)XMPP_genNonce







|





|







389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
				       length: [data count] *
					       [data itemSize]];
	value = [mess substringWithRange: of_range(2, [mess length] - 2)];

	if ([mess hasPrefix: @"v="]) {
		if (![value isEqual: [serverSignature stringByBase64Encoding]])
			@throw [XMPPAuthFailedException
			    exceptionWithClass: [self class]
				    connection: nil
					reason: @"Received wrong "
						@"ServerSignature"];
		authenticated = YES;
	} else
		@throw [XMPPAuthFailedException exceptionWithClass: [self class]
							connection: nil
							    reason: value];

	return nil;
}

- (OFString*)XMPP_genNonce

Modified src/XMPPSRVLookup.m from [09348b639a] to [4cdbc19657].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
	return [[[self alloc] initWithResourceRecord: resourceRecord
					      handle: handle] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithPriority: (uint16_t)priority_
	    weight: (uint16_t)weight_







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
	return [[[self alloc] initWithResourceRecord: resourceRecord
					      handle: handle] autorelease];
}

- init
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithPriority: (uint16_t)priority_
	    weight: (uint16_t)weight_
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
		priority = ntohs(rdata[0]);
		weight = ntohs(rdata[1]);
		port = ntohs(rdata[2]);

		if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
		    (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: isa];

		target = [[OFString alloc]
		    initWithCString: buffer
			   encoding: OF_STRING_ENCODING_NATIVE];
	} @catch (id e) {
		[self release];
		@throw e;







|







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
		priority = ntohs(rdata[0]);
		weight = ntohs(rdata[1]);
		port = ntohs(rdata[2]);

		if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
		    (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];

		target = [[OFString alloc]
		    initWithCString: buffer
			   encoding: OF_STRING_ENCODING_NATIVE];
	} @catch (id e) {
		[self release];
		@throw e;
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
	[target release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<%@ priority: %" PRIu16
					   @", weight: %" PRIu16
					   @", target: %@:%" PRIu16 @">",
					   isa, priority, weight, target, port];
}

- (uint16_t)priority
{
	return priority;
}








|
|
<
|







116
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132
	[target release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"<%@ priority: %" PRIu16 @", weight: %" PRIu16 @", target: %@:%"

	    PRIu16 @">", [self class], priority, weight, target, port];
}

- (uint16_t)priority
{
	return priority;
}

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&resState))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: isa
					socket: nil
					  host: domain];

		answer = [self allocMemoryWithSize: 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;

		if (answerLen < 1 || answerLen > of_pagesize) {
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: isa
					socket: nil
					  host: domain];
		}

		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: isa
					socket: nil
					  host: domain];

		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;







|














|






|







203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&resState))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]
					socket: nil
					  host: domain];

		answer = [self allocMemoryWithSize: 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;

		if (answerLen < 1 || answerLen > of_pagesize) {
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]
					socket: nil
					  host: domain];
		}

		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]
					socket: nil
					  host: domain];

		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;

Modified src/XMPPStanza.m from [efa3deac21] to [fbf43a1a52].

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
	self = [super initWithName: name_
			 namespace: XMPP_NS_CLIENT];

	@try {
		if (![name_ isEqual: @"iq"] && ![name_ isEqual: @"message"] &&
		    ![name_ isEqual: @"presence"])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		[self setDefaultNamespace: XMPP_NS_CLIENT];
		[self setPrefix: @"stream"
		   forNamespace: XMPP_NS_STREAM];

		if (type_ != nil)







|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
	self = [super initWithName: name_
			 namespace: XMPP_NS_CLIENT];

	@try {
		if (![name_ isEqual: @"iq"] && ![name_ isEqual: @"message"] &&
		    ![name_ isEqual: @"presence"])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		[self setDefaultNamespace: XMPP_NS_CLIENT];
		[self setPrefix: @"stream"
		   forNamespace: XMPP_NS_STREAM];

		if (type_ != nil)

Modified src/XMPPXMLElementBuilder.m from [646ad5b19d] to [2fa5bac2f8].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

#import <ObjFW/OFMalformedXMLException.h>

@implementation XMPPXMLElementBuilder
-		 (void)parser: (OFXMLParser*)parser
  foundProcessingInstructions: (OFString*)pi
{
	@throw [OFMalformedXMLException exceptionWithClass: isa];
}

- (void)parser: (OFXMLParser*)parser
  foundComment: (OFString*)comment
{
	@throw [OFMalformedXMLException exceptionWithClass: isa];
}
@end







|





|


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

#import <ObjFW/OFMalformedXMLException.h>

@implementation XMPPXMLElementBuilder
-		 (void)parser: (OFXMLParser*)parser
  foundProcessingInstructions: (OFString*)pi
{
	@throw [OFMalformedXMLException exceptionWithClass: [self class]];
}

- (void)parser: (OFXMLParser*)parser
  foundComment: (OFString*)comment
{
	@throw [OFMalformedXMLException exceptionWithClass: [self class]];
}
@end