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

Side by Side 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: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.webview_shell; 5 package org.chromium.webview_shell;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.annotation.SuppressLint; 8 import android.annotation.SuppressLint;
9 import android.annotation.TargetApi; 9 import android.annotation.TargetApi;
10 import android.app.Activity; 10 import android.app.Activity;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 import android.widget.EditText; 43 import android.widget.EditText;
44 import android.widget.FrameLayout; 44 import android.widget.FrameLayout;
45 import android.widget.PopupMenu; 45 import android.widget.PopupMenu;
46 import android.widget.TextView; 46 import android.widget.TextView;
47 47
48 import org.chromium.base.Log; 48 import org.chromium.base.Log;
49 49
50 import java.lang.reflect.InvocationTargetException; 50 import java.lang.reflect.InvocationTargetException;
51 import java.lang.reflect.Method; 51 import java.lang.reflect.Method;
52 52
53 import java.net.URI;
54 import java.net.URISyntaxException;
55
56 import java.util.ArrayList; 53 import java.util.ArrayList;
57 import java.util.HashMap; 54 import java.util.HashMap;
58 import java.util.List; 55 import java.util.List;
59 import java.util.regex.Matcher; 56 import java.util.regex.Matcher;
60 import java.util.regex.Pattern; 57 import java.util.regex.Pattern;
61 58
62 /** 59 /**
63 * This activity is designed for starting a "mini-browser" for manual testing of WebView. 60 * This activity is designed for starting a "mini-browser" for manual testing of WebView.
64 * It takes an optional URL as an argument, and displays the page. There is a UR L bar 61 * It takes an optional URL as an argument, and displays the page. There is a UR L bar
65 * on top of the webview for manually specifying URLs to load. 62 * on top of the webview for manually specifying URLs to load.
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 request.deny(); 391 request.deny();
395 return; 392 return;
396 } 393 }
397 } 394 }
398 request.grant(request.getResources()); 395 request.grant(request.getResources());
399 mPendingRequests.delete(requestCode); 396 mPendingRequests.delete(requestCode);
400 } 397 }
401 398
402 public void loadUrlFromUrlBar(View view) { 399 public void loadUrlFromUrlBar(View view) {
403 String url = mUrlBar.getText().toString(); 400 String url = mUrlBar.getText().toString();
404 try { 401 // Parse with android.net.Uri instead of java.net.URI because Uri does n o validation. Rather
405 URI uri = new URI(url); 402 // than failing, illegal characters should just be passed through to Web View, which will
406 url = (uri.getScheme() == null) ? "http://" + uri.toString() : uri.t oString(); 403 // escape them where appropriate.
407 } catch (URISyntaxException e) { 404 if (Uri.parse(url).getScheme() == null) url = "http://" + url;
timvolodine 2017/02/02 01:32:35 I think the original code also meant to catch thin
paulmiller 2017/02/02 01:43:20 No, but I don't think we need to. If you give WebV
408 String message = "<html><body>URISyntaxException: " + e.getMessage() + "</body></html>";
409 mWebView.loadData(message, "text/html", "UTF-8");
410 setUrlFail(true);
411 return;
412 }
413
414 setUrlBarText(url); 405 setUrlBarText(url);
415 setUrlFail(false); 406 setUrlFail(false);
416 loadUrl(url); 407 loadUrl(url);
417 hideKeyboard(mUrlBar); 408 hideKeyboard(mUrlBar);
418 } 409 }
419 410
420 public void showPopup(View v) { 411 public void showPopup(View v) {
421 PopupMenu popup = new PopupMenu(this, v); 412 PopupMenu popup = new PopupMenu(this, v);
422 popup.setOnMenuItemClickListener(this); 413 popup.setOnMenuItemClickListener(this);
423 popup.inflate(R.menu.main_menu); 414 popup.inflate(R.menu.main_menu);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 } 584 }
594 } 585 }
595 return false; 586 return false;
596 } 587 }
597 588
598 private static boolean isNullOrGenericHandler(IntentFilter filter) { 589 private static boolean isNullOrGenericHandler(IntentFilter filter) {
599 return filter == null 590 return filter == null
600 || (filter.countDataAuthorities() == 0 && filter.countDataPaths( ) == 0); 591 || (filter.countDataAuthorities() == 0 && filter.countDataPaths( ) == 0);
601 } 592 }
602 } 593 }
OLDNEW
« 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