ObjXMPP  Check-in [0d872572ac]

Overview
Comment:Perform IDNA's ToASCII operation on the server's domain name
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0d872572ac74ea52b58c321bb535c9178b8808c4e082546055f6ff4beebd344b
User & Date: florob@babelmonkeys.de on 2011-02-18 00:56:41
Other Links: manifest | tags
Context
2011-02-19
15:08
Remove old attributes before adding new ones. check-in: 51f917ae30 user: js tags: trunk
2011-02-18
00:56
Perform IDNA's ToASCII operation on the server's domain name check-in: 0d872572ac user: florob@babelmonkeys.de tags: trunk
2011-02-17
11:27
Add docs/ to .hgignore check-in: 717f76ff69 user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPConnection.m from [e746d2539e] to [162b90dd45].

20
21
22
23
24
25
26

27
28
29
30
31
32
33
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34







+







 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <assert.h>

#include <stringprep.h>
#include <idna.h>

#import "XMPPConnection.h"
#import "XMPPStanza.h"
#import "XMPPJID.h"
#import "XMPPIQ.h"
#import "XMPPExceptions.h"

112
113
114
115
116
117
118
119

120
121
122
123
124
125
126







127
128
129
130
131
132
133
113
114
115
116
117
118
119

120
121






122
123
124
125
126
127
128
129
130
131
132
133
134
135







-
+

-
-
-
-
-
-
+
+
+
+
+
+
+







	[old release];
}

- (void)setServer: (OFString*)server_
{
	OFString *old = server;
	char *srv;
	Stringprep_rc rc;
	Idna_rc rc;

	if ((rc = stringprep_profile([server_ cString], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"Nameprep"
							    string: server_];
	if ((rc = idna_to_ascii_8z([server_ cString],
	    &srv, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS)
		@throw [XMPPIDNATranslationFailedException
		 newWithClass: isa
		   connection: self
		    operation: @"ToASCII"
		       string: server_];

	@try {
		server = [[OFString alloc] initWithCString: srv];
	} @finally {
		free(srv);
	}

Modified src/XMPPExceptions.h from [49bb8b74db] to [c92946c52e].

50
51
52
53
54
55
56


















50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
       profile: (OFString*)profile
	string: (OFString*)string;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
	profile: (OFString*)profile
	 string: (OFString*)string;
@end

@interface XMPPIDNATranslationFailedException: XMPPException
{
	OFString *operation;
	OFString *string;
}

@property (readonly, nonatomic) OFString *operation, *string;

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
     operation: (OFString*)operation
	string: (OFString*)string;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
      operation: (OFString*)operation
	 string: (OFString*)string;
@end

Modified src/XMPPExceptions.m from [529c7ab5af] to [efe19df829].

136
137
138
139
140
141
142



































































143
144
145
146
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




		return description;

	pool = [[OFAutoreleasePool alloc] init];
	description = [[OFString alloc] initWithFormat:
	    @"Stringprep with profile %@ failed on string '%@'!",
	    profile, string];
	[pool release];

	return description;
}
@end

@implementation XMPPIDNATranslationFailedException
@synthesize operation, string;

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
     operation: (OFString*)operation
	string: (OFString*)string
{
	return [[self alloc] initWithClass: class_
				connection: conn
				 operation: operation
				    string: string];
}

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

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
      operation: (OFString*)operation_
	 string: (OFString*)string_
{
	self = [super initWithClass: class_
			 connection: conn];

	@try {
		operation = [operation_ copy];
		string = [string_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[operation release];
	[string release];

	[super dealloc];
}

- (OFString*)description
{
	OFAutoreleasePool *pool;

	if (description != nil)
		return description;

	pool = [[OFAutoreleasePool alloc] init];
	description = [[OFString alloc] initWithFormat:
	    @"IDNA operation %@ failed on string '%@'!",
	    operation, string];
	[pool release];

	return description;
}
@end