ObjFW  Diff

Differences From Artifact [52af0e7dc7]:

To Artifact [1b09d47d68]:


27
28
29
30
31
32
33





34
35
36
37
38
39
40

/* Reference for static linking */
int _OFString_URLEncoding_reference;

@implementation OFString (URLEncoding)
- (OFString*)stringByURLEncoding
{





	void *pool = objc_autoreleasePoolPush();
	const char *string = [self UTF8String];
	char *retCString;
	size_t i;
	OFString *ret;

	/*







>
>
>
>
>







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

/* Reference for static linking */
int _OFString_URLEncoding_reference;

@implementation OFString (URLEncoding)
- (OFString*)stringByURLEncoding
{
	return [self stringByURLEncodingWithIgnoredCharacters: ""];
}

- (OFString*)stringByURLEncodingWithIgnoredCharacters: (const char*)ignored
{
	void *pool = objc_autoreleasePoolPush();
	const char *string = [self UTF8String];
	char *retCString;
	size_t i;
	OFString *ret;

	/*
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
		 * '+' is also listed in RFC 1738, however, '+' is sometimes
		 * interpreted as space in HTTP. Therefore always escape it to
		 * make sure it's always interpreted correctly.
		 */
		if (!(*string & 0x80) && (isalnum((int)*string) ||
		    *string == '$' || *string == '-' || *string == '_' ||
		    *string == '.' || *string == '!' || *string == '*' ||
		    *string == '(' || *string == ')' || *string == ','))

			retCString[i++] = *string;
		else {
			uint8_t high, low;

			high = *string >> 4;
			low = *string & 0x0F;








|
>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
		 * '+' is also listed in RFC 1738, however, '+' is sometimes
		 * interpreted as space in HTTP. Therefore always escape it to
		 * make sure it's always interpreted correctly.
		 */
		if (!(*string & 0x80) && (isalnum((int)*string) ||
		    *string == '$' || *string == '-' || *string == '_' ||
		    *string == '.' || *string == '!' || *string == '*' ||
		    *string == '(' || *string == ')' || *string == ',' ||
		    strchr(ignored, *string) != NULL))
			retCString[i++] = *string;
		else {
			uint8_t high, low;

			high = *string >> 4;
			low = *string & 0x0F;