ObjFW  Check-in [31dbd46481]

Overview
Comment:URL encoding: Make sure an unsigned shift is used
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 0.8
Files: files | file ages | folders
SHA3-256: 31dbd464810134d0a087b877d7e3dcc2e83365fe2a284be3359f26ac6b726fc4
User & Date: js on 2016-03-28 19:35:19
Other Links: branch diff | manifest | tags
Context
2016-04-18
17:21
Improve of_condition_wait error handling on Win32 check-in: 0e4c54215b user: js tags: 0.8
2016-03-28
19:35
URL encoding: Make sure an unsigned shift is used check-in: 31dbd46481 user: js tags: 0.8
2016-03-20
15:25
OFHTTPServer: Delegate for client socket exception check-in: 3b20e90066 user: js tags: 0.8
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');
		}