[TIMOB-24695] Android: ImageView.image fails when URL contains multiple question marks
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-06-28T22:03:46.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.2.0 |
Components | Android |
Labels | imageview |
Reporter | Dan Noa |
Assignee | Joshua Quick |
Created | 2017-05-14T11:39:19.000+0000 |
Updated | 2017-08-17T01:48:12.000+0000 |
Description
when the imageView path that contains multiple '?' symbol it will not get be encoded properly on Android.
Sample Url:
[http://scontent.xx.fbcdn.net.rsz.io/v/t1.0-9/s720x720/17795851_419371511758070_7481565181564022529_n.jpg?oh=7772aea44d2f40fdbd42285ca61d7aac&oe=59771D60?mode=crop&width=333&height=250]
Notice there is 2 '?' in the url, the second one is encoded to %%3F by android as shown below:
[http://scontent.xx.fbcdn.net.rsz.io/v/t1.0-9/s720x720/17795851_419371511758070_7481565181564022529_n.jpg?oh=7772aea44d2f40fdbd42285ca61d7aac&oe=59771D60%%3Fmode=crop&width=333&height=250]
I tried using encodeUri but android still appends a % before the %3F symbol.
Steps:
1. Run sample code
2. Check image in the browser to verify the URL is valid.
Actual: Image does not appear
Expected: Image must appear
var window = Titanium.UI.createWindow({
});
var imageview = Ti.UI.createImageView({
image:'http://scontent.xx.fbcdn.net.rsz.io/v/t1.0-9/s720x720/17795851_419371511758070_7481565181564022529_n.jpg?oh=7772aea44d2f40fdbd42285ca61d7aac&oe=59771D60?mode=crop&width=333&height=250'
})
window.add(imageview);
window.open();
Logs:
[ERROR] : TiDownloadManager: (pool-3-thread-1) [1302,1302] Exception downloading http://scontent.xx.fbcdn.net.rsz.io/v/t1.0-9/s720x720/17795851_419371511758070_7481565181564022529_n.jpg?oh=7772aea44d2f40fdbd42285ca61d7aac&oe=59771D60%%3Fmode=crop&width=333&height=250
[ERROR] : TiDownloadManager: java.io.FileNotFoundException: http://scontent.xx.fbcdn.net.rsz.io/v/t1.0-9/s720x720/17795851_419371511758070_7481565181564022529_n.jpg?oh=7772aea44d2f40fdbd42285ca61d7aac&oe=59771D60%%3Fmode=crop&width=333&height=250
[ERROR] : TiDownloadManager: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238)
[ERROR] : TiDownloadManager: at java.net.URL.openStream(URL.java:470)
[ERROR] : TiDownloadManager: at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:135)
[ERROR] : TiDownloadManager: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
[ERROR] : TiDownloadManager: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
[ERROR] : TiDownloadManager: at java.lang.Thread.run(Thread.java:818)
The second URL doesn't even run on normal browsers, it's throwing n 403 error. So probably it's linked to an access token or authorized content, this is no Android issue.
Yes it will not run because it has wrongly been encoded on Android. Same url works perfectly on ios. If you check the sample url i posted, you will see it's a valid one and loads properly in the browser.
Ok, it's clear now. So it's not the loading of the URL but the encoding of it. Waiting for support to validate it, but it looks valid for me!
Hello, I can verify the issue in Android. The image does not load and there is the error. Tested with SDK 6.0.4.GA and CLI 6.2.0. Tested in Android 6.0.2.device. Working for iOS though. Tested with 10.2 simulator. Moving to engineering.
-master:
https://github.com/appcelerator/titanium_mobile/pull/9097
-PR (master): https://github.com/appcelerator/titanium_mobile/pull/9178
FR Passed.
Verified the fix in SDK 7.0.0.v20170816113226 & 6.2.0.v20170816173122. Closing. Studio Ver: 4.9.1.201707200100 SDK Ver: 6.2.0.v20170816173122, 7.0.0.v20170816113226 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.9 Appc CLI: 6.2.3 Ti CLI Ver: 5.0.14 Alloy Ver: 1.9.13 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1