diff options
Diffstat (limited to 'core/java/android/webkit/URLUtil.java')
-rw-r--r-- | core/java/android/webkit/URLUtil.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/core/java/android/webkit/URLUtil.java b/core/java/android/webkit/URLUtil.java index 9889fe9..232ed36 100644 --- a/core/java/android/webkit/URLUtil.java +++ b/core/java/android/webkit/URLUtil.java @@ -61,7 +61,7 @@ public final class URLUtil { webAddress = new WebAddress(inUrl); } catch (ParseException ex) { - if (WebView.LOGV_ENABLED) { + if (DebugFlags.URL_UTIL) { Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl); } return retVal; @@ -126,6 +126,32 @@ public final class URLUtil { return retData; } + /** + * @return True iff the url is correctly URL encoded + */ + static boolean verifyURLEncoding(String url) { + int count = url.length(); + if (count == 0) { + return false; + } + + int index = url.indexOf('%'); + while (index >= 0 && index < count) { + if (index < count - 2) { + try { + parseHex((byte) url.charAt(++index)); + parseHex((byte) url.charAt(++index)); + } catch (IllegalArgumentException e) { + return false; + } + } else { + return false; + } + index = url.indexOf('%', index + 1); + } + return true; + } + private static int parseHex(byte b) { if (b >= '0' && b <= '9') return (b - '0'); if (b >= 'A' && b <= 'F') return (b - 'A' + 10); @@ -146,6 +172,7 @@ public final class URLUtil { * requests from a file url. * @deprecated Cookieless proxy is no longer supported. */ + @Deprecated public static boolean isCookielessProxyUrl(String url) { return (null != url) && url.startsWith(PROXY_BASE); } |