Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8376] iOS: Improper URL reencoding on 302 FOUND redirect for 1.8/2.0 SDK

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-10T18:02:29.000+0000
Affected Version/sRelease 1.8.0.1, Release 1.8.1, Release 1.8.2, Release 2.0.1
Fix Version/sn/a
ComponentsiOS
Labelsparity
ReporterTrent Walkiewicz
AssigneeUnknown
Created2012-02-23T14:40:54.000+0000
Updated2020-01-10T18:02:29.000+0000

Description

Problem Description

When following the location header of a 302 FOUND redirect, an already URL encoded URL is then encoded again (for example the value %3D becomes %253D as the percent sign is URL encoded). This does not happen on 1.7.5 SDK, only 1.8.0.1 and 1.8.1

Actual Results

the URL being reencoded

Expected REsults

if the URL is encoded, don't reencode.

Test Case

*Example* 1. xhr request is made to http://www.dropbox.com/u/18787705/app%3Dlogo.jpeg 2. Response is 302 FOUND with location header of http://dl-web.dropbox.com/u/18787705/app%3Dlogo.jpeg 3. Under 1.8 SDK a request is then made to http://dl-web.dropbox.com/u/18787705/app%253Dlogo.jpeg (note how the % is encoded to %25) 4. A 404 is returned as this evaluates to a filename of "app%3Dlogo.jpeg" instead of "app=logo.jpeg" as expected The sample code below shows that this is a problem both with HTTPClient object as well as the remote image property of imageviews (toggle the makeXhrRequest variable to try both ways). The following successfully returns an image both ways under 1.7.5 SDK
var makeXhrRequest = false;

var win = Titanium.UI.createWindow();
var img = Ti.UI.createImageView();

if(makeXhrRequest){
	var xhr = Titanium.Network.createHTTPClient();

	xhr.onload = function() {
		img.image = this.responseData;
	};
 	xhr.open("GET", 'http://www.dropbox.com/u/18787705/app%3Dlogo.jpeg');
 	xhr.send();
 	
} else {
	img.image = 'http://www.dropbox.com/u/18787705/app%3Dlogo.jpeg';
}

win.add(img);
win.open();

Comments

  1. Trent Walkiewicz 2012-03-01

    Just tested in 1.8.2 SDK and the problem persists. This problem is forcing me to stick to 1.7.5
  2. Junaid Younus 2012-05-21

    Tested with 2.0.1GA2 on the iOS simulator, issue still exists. Seems to work fine on Android.
  3. roeland 2012-10-08

    Tested with 2.1.2GA and problem still exists both in iOS simulator and Device. For me however it used to work also in versions up to 1.8.2 but during that period I used a rather low iOS SDK instead: 4.3. Now with a brandnew computer, 2.1.2GA and iOS SDK 6.0 I also face this problem/bug. My workaround is by rawurlencoding the 'URL to 302 to' serverside before the actual header: 'Location' is returned to the xhr/client. But I think that's suboptimal. More comments at https://developer.appcelerator.com/question/132556/improper-url-encoding-for-302-found-on-18
  4. roeland 2012-10-08

    *
  5. Alan Hutton 2020-01-10

    This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source