Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1952] Android: Escaped ampersand in URI query string gets unescaped thus breaking XHR calls

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:57:38.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, defect
ReporterBill Dawson
AssigneeBill Dawson
Created2011-04-15T03:06:23.000+0000
Updated2011-04-17T01:57:38.000+0000

Description

cf this commit:

http://github.com/appcelerator/titanium_mobile/commit/768616c5f7595b621c75cb35a8abdccb74461f3e"> http://github.com/appcelerator/titanium_mobile/commit/768616c5f7595...

We've had a problem in the past with partially escaped query strings -- unfortunately that commit referenced above does not itself reference a ticket. Anyway, because of partially escaped query strings, we unescape and then re-escape the query string in order to ensure the full string is escaped. But in re-escaping, we do not escape the ampersand because of its status as a field separator. But now this unescape/re-escape causes a problem for query strings that really did want the ampersand escaped.

Fail case app.js:

var URL = "http://www.google.com/m/search?q=test%26junk";
Titanium.UI.setBackgroundColor('#000');
var xhr = Ti.Network.createHTTPClient();
xhr.open('GET', URL);
xhr.send();
Ti.API.info(xhr.location);

When you run that, on the console you'll see that the url becomes http://www.google.com/m/search?q=test&;junk, when it's expected to have that ampersand stay as %26.

Comments

  1. Bill Dawson 2011-04-15

    Actually an earlier commit references ticket #1491 and helpdesk http://developer.appcelerator.com/helpdesk/view/34201">http://developer.appcelerator.com/helpdesk/view/34201

  2. Bill Dawson 2011-04-15

    (from [34363f9c2020a21cd4038c9160cce39b38a8c1b3]) [#1952 state:fixed-in-qa] If user (developer) supplies escaped characters (%xx) in query string, don't encode the uri http://github.com/appcelerator/titanium_mobile/commit/34363f9c2020a21cd4038c9160cce39b38a8c1b3"> http://github.com/appcelerator/titanium_mobile/commit/34363f9c2020a...

  3. Thomas Huelbert 2011-04-15

    1.4.2.4ce7ff G1 running 1.6, 2.2 simulator

JSON Source