Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2164)

Unified Diff: android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java

Issue 2668273003: WebView shell: automatically escape URLs (Closed)
Patch Set: more descriptive Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
diff --git a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
index c8b3ae75e7903f68545beb872fadb7dad0d1a847..1c6f972e6af395a913ab29247b5dba2db78cfaff 100644
--- a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
+++ b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
@@ -50,9 +50,6 @@ import org.chromium.base.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -401,16 +398,10 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
public void loadUrlFromUrlBar(View view) {
String url = mUrlBar.getText().toString();
- try {
- URI uri = new URI(url);
- url = (uri.getScheme() == null) ? "http://" + uri.toString() : uri.toString();
- } catch (URISyntaxException e) {
- String message = "<html><body>URISyntaxException: " + e.getMessage() + "</body></html>";
- mWebView.loadData(message, "text/html", "UTF-8");
- setUrlFail(true);
- return;
- }
-
+ // Parse with android.net.Uri instead of java.net.URI because Uri does no validation. Rather
+ // than failing in the browser, let WebView handle weird URLs. WebView will escape illegal
+ // characters and display error pages for bad URLs like "blah://example.com".
+ if (Uri.parse(url).getScheme() == null) url = "http://" + url;
setUrlBarText(url);
setUrlFail(false);
loadUrl(url);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698