ObjFW  Check-in [179c625d15]

Overview
Comment:URL encoding: Make sure an unsigned shift is used
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 179c625d15b7eb8d070ca325b19737a774126be4422432bf573ef07ade77008b
User & Date: js on 2016-03-28 19:33:50
Other Links: manifest | tags
Context
2016-03-28
19:50
socket.m: Remove leftover from port registry check-in: 9394805757 user: js tags: trunk
19:33
URL encoding: Make sure an unsigned shift is used check-in: 179c625d15 user: js tags: trunk
16:50
Change the definition of thread priorities check-in: b4023e6bc0 user: js tags: trunk
Changes

Modified src/OFString+URLEncoding.m from [2cd0023e53] to [18f43044b2].

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
	 * @"" literal.
	 */
	if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithRequestedSize:
		    ([self UTF8StringLength] * 3) + 1];

	for (i = 0; *string != '\0'; string++) {


		/*
		 * '+' 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;

			retCString[i++] = '%';
			retCString[i++] =
			    (high > 9 ? high - 10 + 'A' : high + '0');
			retCString[i++] =
			    (low  > 9 ? low  - 10 + 'A' : low  + '0');
		}







>
>





|
|
<
<
|
|

|

|
|







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
	 * @"" literal.
	 */
	if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithRequestedSize:
		    ([self UTF8StringLength] * 3) + 1];

	for (i = 0; *string != '\0'; string++) {
		unsigned char c = *string;

		/*
		 * '+' 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 (!(c & 0x80) && (isalnum(c) || c == '$' || c == '-' ||
		    c == '_' || c == '.' || c == '!' || c == '*' || c == '(' ||


		    c == ')' || c == ',' || strchr(ignored, c) != NULL))
			retCString[i++] = c;
		else {
			unsigned char high, low;

			high = c >> 4;
			low = c & 0x0F;

			retCString[i++] = '%';
			retCString[i++] =
			    (high > 9 ? high - 10 + 'A' : high + '0');
			retCString[i++] =
			    (low  > 9 ? low  - 10 + 'A' : low  + '0');
		}