ObjFW  Diff

Differences From Artifact [f265de725c]:

To Artifact [a82a35d7aa]:


48
49
50
51
52
53
54


















55
56
57
58
59
60

61
62
63
64
65
66
67
@end

@interface OFURIQueryOrFragmentAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end

@interface OFURIQueryKeyValueAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end



















static OFCharacterSet *URIAllowedCharacterSet = nil;
static OFCharacterSet *URISchemeAllowedCharacterSet = nil;
static OFCharacterSet *URIPathAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryOrFragmentAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryKeyValueAllowedCharacterSet = nil;


static OFOnceControl URIAllowedCharacterSetOnce = OFOnceControlInitValue;
static OFOnceControl URIQueryOrFragmentAllowedCharacterSetOnce =
    OFOnceControlInitValue;

static void
initURIAllowedCharacterSet(void)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>







48
49
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
75
76
77
78
79
80
81
82
83
84
85
86
@end

@interface OFURIQueryOrFragmentAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end

@interface OFURIQueryKeyValueAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end

@interface OFURIPathAllowedCharacterSetWithoutExclamationMark:
    OFURIPathAllowedCharacterSet
{
	OFCharacterSet *_characterSet;
	bool (*_characterIsMember)(id, SEL, OFUnichar);
}
@end

OF_DIRECT_MEMBERS
@interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet
{
	OFCharacterSet *_characterSet;
	bool (*_characterIsMember)(id, SEL, OFUnichar);
}

- (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet;
@end

static OFCharacterSet *URIAllowedCharacterSet = nil;
static OFCharacterSet *URISchemeAllowedCharacterSet = nil;
static OFCharacterSet *URIPathAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryOrFragmentAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryKeyValueAllowedCharacterSet = nil;
static OFCharacterSet *URIPathAllowedCharacterSetWithoutExclamationMark = nil;

static OFOnceControl URIAllowedCharacterSetOnce = OFOnceControlInitValue;
static OFOnceControl URIQueryOrFragmentAllowedCharacterSetOnce =
    OFOnceControlInitValue;

static void
initURIAllowedCharacterSet(void)
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
static void
initURIQueryKeyValueAllowedCharacterSet(void)
{
	URIQueryKeyValueAllowedCharacterSet =
	    [[OFURIQueryKeyValueAllowedCharacterSet alloc] init];
}

OF_DIRECT_MEMBERS

@interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet
{
	OFCharacterSet *_characterSet;
	bool (*_characterIsMember)(id, SEL, OFUnichar);
}

- (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet;
@end

bool
OFURIIsIPv6Host(OFString *host)
{
	const char *UTF8String = host.UTF8String;
	bool hasColon = false;








<
>
|

|
|

<
<
<







112
113
114
115
116
117
118

119
120
121
122
123
124



125
126
127
128
129
130
131
static void
initURIQueryKeyValueAllowedCharacterSet(void)
{
	URIQueryKeyValueAllowedCharacterSet =
	    [[OFURIQueryKeyValueAllowedCharacterSet alloc] init];
}


static void
initURIPathAllowedCharacterSetWithoutExclamationMark(void)
{
	URIPathAllowedCharacterSetWithoutExclamationMark =
	    [[OFURIPathAllowedCharacterSetWithoutExclamationMark alloc] init];
}




bool
OFURIIsIPv6Host(OFString *host)
{
	const char *UTF8String = host.UTF8String;
	bool hasColon = false;

286
287
288
289
290
291
292

































293
294
295
296
297
298
299
	case '?':
		return true;
	default:
		return false;
	}
}
@end


































@implementation OFInvertedCharacterSetWithoutPercent
- (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet
{
	self = [super init];

	@try {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
	case '?':
		return true;
	default:
		return false;
	}
}
@end

@implementation OFURIPathAllowedCharacterSetWithoutExclamationMark
- (instancetype)init
{
	self = [super init];

	@try {
		_characterSet = [[OFCharacterSet URIPathAllowedCharacterSet]
		    retain];
		_characterIsMember = (bool (*)(id, SEL, OFUnichar))
		    [_characterSet methodForSelector:
		    @selector(characterIsMember:)];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_characterSet release];

	[super dealloc];
}

- (bool)characterIsMember: (OFUnichar)character
{
	return (character != '!' && _characterIsMember(_characterSet,
	    @selector(characterIsMember:), character));
}
@end

@implementation OFInvertedCharacterSetWithoutPercent
- (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet
{
	self = [super init];

	@try {
394
395
396
397
398
399
400









401
402
403
404
405
406
407
+ (OFCharacterSet *)URIFragmentAllowedCharacterSet
{
	OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce,
	    initURIQueryOrFragmentAllowedCharacterSet);

	return URIQueryOrFragmentAllowedCharacterSet;
}









@end

@implementation OFURI
+ (instancetype)URI
{
	return [[[self alloc] init] autorelease];
}







>
>
>
>
>
>
>
>
>







443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
+ (OFCharacterSet *)URIFragmentAllowedCharacterSet
{
	OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce,
	    initURIQueryOrFragmentAllowedCharacterSet);

	return URIQueryOrFragmentAllowedCharacterSet;
}

+ (OFCharacterSet *)of_URIPathAllowedCharacterSetWithoutExclamationMark
{
	static OFOnceControl onceControl = OFOnceControlInitValue;
	OFOnce(&onceControl,
	    initURIPathAllowedCharacterSetWithoutExclamationMark);

	return URIPathAllowedCharacterSetWithoutExclamationMark;
}
@end

@implementation OFURI
+ (instancetype)URI
{
	return [[[self alloc] init] autorelease];
}