summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2012-06-13 14:51:23 -0700
committerSelim Gurun <sgurun@google.com>2012-06-13 15:04:41 -0700
commita770f8d4bd583e9a719af6ce314838db12003b33 (patch)
tree5771fd3ae79703562b631a2a83339c0fa81450e4 /src/com
parenteb2c7c2d3f4ddb0ebeab2a2d5537b208cf666db1 (diff)
downloadpackages_apps_Browser-a770f8d4bd583e9a719af6ce314838db12003b33.zip
packages_apps_Browser-a770f8d4bd583e9a719af6ce314838db12003b33.tar.gz
packages_apps_Browser-a770f8d4bd583e9a719af6ce314838db12003b33.tar.bz2
Encode characters that java.net.URI rejects
Bug: 5952386 Our java.net.URI implementation conforms to an old obsolete RFC and it is very restrictive. Since in our download path, we use download manager and so java.net.URI, this causes an odd bug (i.e. URIs that are fetched fine by chromium http stack fails when download manager is used). Also there is a second bug that when URI parsing fails and an exception is thrown, we fail to catch it and crash. This CL fixes both. Change-Id: I62ac289566efae97dd2161b8041b06a0a87211cb
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/browser/DownloadHandler.java4
-rw-r--r--src/com/android/browser/FetchUrlMimeType.java16
2 files changed, 15 insertions, 5 deletions
diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java
index 6e2c786..219114e 100644
--- a/src/com/android/browser/DownloadHandler.java
+++ b/src/com/android/browser/DownloadHandler.java
@@ -107,7 +107,7 @@ public class DownloadHandler {
boolean needed = false;
for (char c : chars) {
- if (c == '[' || c == ']') {
+ if (c == '[' || c == ']' || c == '|') {
needed = true;
break;
}
@@ -118,7 +118,7 @@ public class DownloadHandler {
StringBuilder sb = new StringBuilder("");
for (char c : chars) {
- if (c == '[' || c == ']') {
+ if (c == '[' || c == ']' || c == '|') {
sb.append('%');
sb.append(Integer.toHexString(c));
} else {
diff --git a/src/com/android/browser/FetchUrlMimeType.java b/src/com/android/browser/FetchUrlMimeType.java
index 845bcc7..07c9b93 100644
--- a/src/com/android/browser/FetchUrlMimeType.java
+++ b/src/com/android/browser/FetchUrlMimeType.java
@@ -27,6 +27,7 @@ import android.content.Context;
import android.net.Proxy;
import android.net.http.AndroidHttpClient;
import android.os.Environment;
+import android.util.Log;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
@@ -44,6 +45,8 @@ import java.io.IOException;
*/
class FetchUrlMimeType extends Thread {
+ private final static String LOGTAG = "FetchUrlMimeType";
+
private Context mContext;
private DownloadManager.Request mRequest;
private String mUri;
@@ -64,9 +67,16 @@ class FetchUrlMimeType extends Thread {
// User agent is likely to be null, though the AndroidHttpClient
// seems ok with that.
AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
- HttpHost httpHost = Proxy.getPreferredHttpHost(mContext, mUri);
- if (httpHost != null) {
- ConnRouteParams.setDefaultProxy(client.getParams(), httpHost);
+ HttpHost httpHost;
+ try {
+ httpHost = Proxy.getPreferredHttpHost(mContext, mUri);
+ if (httpHost != null) {
+ ConnRouteParams.setDefaultProxy(client.getParams(), httpHost);
+ }
+ } catch (IllegalArgumentException ex) {
+ Log.e(LOGTAG,"Download failed: " + ex);
+ client.close();
+ return;
}
HttpHead request = new HttpHead(mUri);