Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7501] Android: Network.createHTTPClient - URL not encoded correctly with autoEncodeUrl enabled

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-12T22:43:33.000+0000
Affected Version/sRelease 1.8.1
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterJustin Szczurowski
AssigneeIngo Muschenetz
Created2012-01-29T06:51:43.000+0000
Updated2017-06-12T22:43:33.000+0000

Description

Problem

Using HTTPClient, the URL is not encoded properly with the autoEncodeUrl property set to true (default).

Test case

var socket = Ti.Network.createHTTPClient();

socket.onload = function(){
  /*
    Returns:  http://www.bosscube.com/flash/clock.swf?param1=%20¶m2=%EF%BF%BD%EF%BF%BD
    Expected: http://www.bosscube.com/flash/clock.swf?param1=%20¶m2=%25
  */
  alert(this.location);
  Ti.API.info('this.location: ' + this.location);
};

socket.open("GET", "http://www.bosscube.com/flash/clock.swf?param1=¶m2=%");
socket.send();

Logs

  778          AndroidRuntime  D  >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
  778          AndroidRuntime  D  CheckJNI is ON
  778          AndroidRuntime  D  --- registering native functions ---
   60         ActivityManager  I  Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.appcelerator.testing10/.Testing10Activity }
   60         ActivityManager  I  Start proc com.appcelerator.testing10 for activity com.appcelerator.testing10/.Testing10Activity: pid=784 uid=10040 gids={1015, 3003}
  778          AndroidRuntime  D  Shutting down VM
  784           TiApplication  I  (main) [0,0] checkpoint, app created.
  784           TiApplication  I  (main) [391,391] Titanium 1.8.1 (2012/01/27 17:31 a24502a)
  784               TiFastDev  D  (main) [94,485] Enabling Fastdev on port 33817
  784               TiFastDev  D  (main) [9,494] sent tokens successfully
  784               TiFastDev  D  (main) [1,495] Fastdev session handshake succesful.
  784           TiApplication  I  (main) [9,504] Titanium Javascript runtime: v8
  784           TiApplication  W  (main) [61,565] activity stack is emtpy, unable to get current activity
  784          TiRootActivity  I  (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
  784           TiApplication  W  (main) [119,119] activity stack is emtpy, unable to get current activity
  784           TiApplication  W  (main) [0,119] activity stack is emtpy, unable to get current activity
  784           TiApplication  W  (main) [2,121] activity stack is emtpy, unable to get current activity
  784           TiApplication  E  (KrollRuntimeThread) [922,1043] APP PROXY: ti.modules.titanium.app.AppModule@44f0ced8
  784           TiAssetHelper  D  Fetching "app.js" with Fastdev...
   60     NotificationService  W  Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy@4513c8a0 in package com.appcelerator.testing10
   60         ActivityManager  W  setProcessForeground called on unknown pid: 755
  784           dalvikvm-heap  I  Grow heap (frag case) to 2.932MB for 69224-byte allocation
  784            TiHttpClient  D  (KrollRuntimeThread) [442,1485] Setting ready state to 1
  784          TiRootActivity  I  (main) [0,0] checkpoint, on root activity resume. activity = com.appcelerator.testing10.Testing10Activity@44eba488
   60         ActivityManager  I  Displayed activity com.appcelerator.testing10/.Testing10Activity: 3155 ms (total 3155 ms)
  784            TiHttpClient  D  (TiHttpClient-1) [968,968] Setting ready state to 2
  784            TiHttpClient  D  (TiHttpClient-1) [2,970] Setting ready state to 3
  784            TiHttpClient  D  (TiHttpClient-1) [158,1128] Setting ready state to 4
  784                   ALERT  I  (KrollRuntimeThread) [4,1132] http://www.bosscube.com/flash/clock.swf?param1=¶m2=%EF%BF%BD%EF%BF%BD
  784                   TiAPI  I  this.location: http://www.bosscube.com/flash/clock.swf?param1=¶m2=0.000000E+00FBFBD1.237263E-317FBFBD
  784           TypeConverter  W  jsValueToJavaObject returning null

Related Issues

I've also noticed that parts of the URL are encoded that shouldn't be. For example:
var socket = Ti.Network.createHTTPClient();

socket.onload = function() {
    /*
        Returns:  http://www.example.com/abcdef%3D%3D?param1=example
        Expected: http://www.example.com/abcdef==?param1=example
    */
    alert(this.location);
};

socket.open("GET", "http://www.example.com/abcdef==?param1=example");
socket.send();

Comments

  1. Paul Dowsett 2012-01-30

    Thanks for raising this ticket. In order for me to escalate it to the core team, please would you complete the environment field? Also, a console log of the test case in action would be appreciated. Please review the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist) when raising tickets, and always start with the [JIRA Ticket Template](https://wiki.appcelerator.org/display/guides/JIRA+Ticket+Template) to ensure they are in the recommended format. Thanks
  2. Lee Morris 2017-06-12

    Closing ticket due to the time passed, lack of information and lack of progress. Any problems, please file a new ticket.

JSON Source