Do Nodeprep on username and add Makefile

This commit is contained in:
Florian Zeitz 2011-02-11 00:59:31 +01:00
parent 4bdf81b429
commit fb15fbd391
2 changed files with 27 additions and 0 deletions

4
Makefile Normal file
View file

@ -0,0 +1,4 @@
all: tests
tests: test.m XMPPConnection.m XMPPStanza.m
objfw-compile -o $@ $^ -lidn -Wall -Werror

View file

@ -1,3 +1,5 @@
#include <stringprep.h>
#include <assert.h>
#import "XMPPConnection.h" #import "XMPPConnection.h"
#import "XMPPStanza.h" #import "XMPPStanza.h"
@ -43,6 +45,27 @@
[super dealloc]; [super dealloc];
} }
- (void)setUsername: (OFString*)username_
{
OFString *old = username;
char *node;
Stringprep_rc rc;
if ((rc = stringprep_profile([username_ cString], &node, "Nodeprep", 0))
!= STRINGPREP_OK) {
of_log(@"Nodeprep failed: %s", stringprep_strerror(rc));
assert(0);
}
@try {
username = [[OFString alloc] initWithCString: node];
} @finally {
free(node);
}
[old release];
}
- (void)_startStream - (void)_startStream
{ {
[sock writeFormat: @"<?xml version='1.0'?>\n" [sock writeFormat: @"<?xml version='1.0'?>\n"