ObjFW  Check-in [32bc855af9]

Overview
Comment:OFString+URLEncoding.m: Do not parse + as space

This should only be done for the query string.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 32bc855af92acba4e031ed75c5049d1931f77180762d919cfbd39aa9b48a82d3
User & Date: js on 2016-07-02 23:35:54
Other Links: manifest | tags
Context
2016-07-02
23:35
OFHTTPClient: Properly escape path & query string check-in: c25601d462 user: js tags: trunk
23:35
OFString+URLEncoding.m: Do not parse + as space check-in: 32bc855af9 user: js tags: trunk
22:26
runtime: Add objc_{allocate,register}ClassPair check-in: 5088c339bf user: js tags: trunk
Changes

Modified src/OFString+URLEncoding.m from [18f43044b2] to [134edb9cf7].

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
		    exceptionWithRequestedSize: [self UTF8StringLength] + 1];

	for (i = 0; *string; string++) {
		switch (state) {
		case 0:
			if (*string == '%')
				state = 1;
			else if (*string == '+')
				retCString[i++] = ' ';
			else
				retCString[i++] = *string;
			break;
		case 1:
		case 2:;
			uint8_t shift = (state == 1 ? 4 : 0);








<
<







104
105
106
107
108
109
110


111
112
113
114
115
116
117
		    exceptionWithRequestedSize: [self UTF8StringLength] + 1];

	for (i = 0; *string; string++) {
		switch (state) {
		case 0:
			if (*string == '%')
				state = 1;


			else
				retCString[i++] = *string;
			break;
		case 1:
		case 2:;
			uint8_t shift = (state == 1 ? 4 : 0);

Modified tests/OFStringTests.m from [a324e7bfdc] to [fa45237488].

569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
	    @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56412a9247c"
	    @"3579a329e53a5dc74676b106755e3394f9454a2d42273242615d32f80437d61"])

	TEST(@"-[stringByURLEncoding]",
	    [[@"foo\"ba'_~$" stringByURLEncoding] isEqual: @"foo%22ba%27_%7E$"])

	TEST(@"-[stringByURLDecoding]",
	    [[@"foo%20bar%22+%24" stringByURLDecoding] isEqual: @"foo bar\" $"])

	TEST(@"-[insertString:atIndex:]",
	    (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) &&
	    R([s[0] insertString: @"Àâü"
			 atIndex: 3]) &&
	    [s[0] isEqual: @"π„žΓΆΓΆΓ€ΓΆΓΌΓΆbÀ€"])








|







569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
	    @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56412a9247c"
	    @"3579a329e53a5dc74676b106755e3394f9454a2d42273242615d32f80437d61"])

	TEST(@"-[stringByURLEncoding]",
	    [[@"foo\"ba'_~$" stringByURLEncoding] isEqual: @"foo%22ba%27_%7E$"])

	TEST(@"-[stringByURLDecoding]",
	    [[@"foo%20bar%22+%24" stringByURLDecoding] isEqual: @"foo bar\"+$"])

	TEST(@"-[insertString:atIndex:]",
	    (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) &&
	    R([s[0] insertString: @"Àâü"
			 atIndex: 3]) &&
	    [s[0] isEqual: @"π„žΓΆΓΆΓ€ΓΆΓΌΓΆbÀ€"])