diff options
author | dgn <dgn@chromium.org> | 2016-01-13 09:03:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-13 17:04:48 +0000 |
commit | f69ffa00b8d244d77be3181441c25eb17e32cce7 (patch) | |
tree | 460f3e7d92792b2fea8795410cd50a5bc15b3846 /android_webview/java | |
parent | 227f4bb791d2dcfd2a17f309db5e613e266480e4 (diff) | |
download | chromium_src-f69ffa00b8d244d77be3181441c25eb17e32cce7.zip chromium_src-f69ffa00b8d244d77be3181441c25eb17e32cce7.tar.gz chromium_src-f69ffa00b8d244d77be3181441c25eb17e32cce7.tar.bz2 |
[Android log] Avoid inserting URLs in the pattern to format
URLs might contain strings that the formatting engine would
recognize as substrings to substitute (e.g. "%3A"). Concatenating
URLs to the base string to format when logging can then cause
crashes.
BUG=565969
Review URL: https://codereview.chromium.org/1586663002
Cr-Commit-Position: refs/heads/master@{#369197}
Diffstat (limited to 'android_webview/java')
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwContents.java | 38 | ||||
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwContentsClient.java | 8 |
2 files changed, 23 insertions, 23 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index c2ce4c9..d7e6409 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -1290,7 +1290,7 @@ public class AwContents implements SmartClipProvider, * @param invalidationOnly Flag to call back only on invalidation without providing a picture. */ public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) { - if (TRACE) Log.d(TAG, "enableOnNewPicture=" + enabled); + if (TRACE) Log.d(TAG, "enableOnNewPicture=%s", enabled); if (isDestroyed(WARN)) return; if (invalidationOnly) { mPictureListenerContentProvider = null; @@ -1353,7 +1353,7 @@ public class AwContents implements SmartClipProvider, * WebView.loadUrl. */ public void loadUrl(String url, Map<String, String> additionalHttpHeaders) { - if (TRACE) Log.d(TAG, "loadUrl(extra headers)=" + url); + if (TRACE) Log.d(TAG, "loadUrl(extra headers)=%s", url); if (isDestroyed(WARN)) return; // TODO: We may actually want to do some sanity checks here (like filter about://chrome). @@ -1377,7 +1377,7 @@ public class AwContents implements SmartClipProvider, * WebView.loadUrl. */ public void loadUrl(String url) { - if (TRACE) Log.d(TAG, "loadUrl=" + url); + if (TRACE) Log.d(TAG, "loadUrl=%s", url); if (isDestroyed(WARN)) return; // Early out to match old WebView implementation if (url == null) { @@ -1390,7 +1390,7 @@ public class AwContents implements SmartClipProvider, * WebView.postUrl. */ public void postUrl(String url, byte[] postData) { - if (TRACE) Log.d(TAG, "postUrl=" + url); + if (TRACE) Log.d(TAG, "postUrl=%s", url); if (isDestroyed(WARN)) return; LoadUrlParams params = LoadUrlParams.createLoadHttpPostParams(url, postData); Map<String, String> headers = new HashMap<String, String>(); @@ -1433,7 +1433,7 @@ public class AwContents implements SmartClipProvider, */ public void loadDataWithBaseURL( String baseUrl, String data, String mimeType, String encoding, String historyUrl) { - if (TRACE) Log.d(TAG, "loadDataWithBaseURL=" + baseUrl); + if (TRACE) Log.d(TAG, "loadDataWithBaseURL=%s", baseUrl); if (isDestroyed(WARN)) return; data = fixupData(data); @@ -1458,7 +1458,7 @@ public class AwContents implements SmartClipProvider, Base64.encodeToString(data.getBytes("utf-8"), Base64.DEFAULT), mimeType, true, baseUrl, historyUrl, "utf-8"); } catch (java.io.UnsupportedEncodingException e) { - Log.wtf(TAG, "Unable to load data string " + data, e); + Log.wtf(TAG, "Unable to load data string %s", data, e); return; } } @@ -1628,7 +1628,7 @@ public class AwContents implements SmartClipProvider, * @see View#setHorizontalScrollbarOverlay(boolean) */ public void setHorizontalScrollbarOverlay(boolean overlay) { - if (TRACE) Log.d(TAG, "setHorizontalScrollbarOverlay=" + overlay); + if (TRACE) Log.d(TAG, "setHorizontalScrollbarOverlay=%s", overlay); mOverlayHorizontalScrollbar = overlay; } @@ -1636,7 +1636,7 @@ public class AwContents implements SmartClipProvider, * @see View#setVerticalScrollbarOverlay(boolean) */ public void setVerticalScrollbarOverlay(boolean overlay) { - if (TRACE) Log.d(TAG, "setVerticalScrollbarOverlay=" + overlay); + if (TRACE) Log.d(TAG, "setVerticalScrollbarOverlay=%s", overlay); mOverlayVerticalScrollbar = overlay; } @@ -1780,7 +1780,7 @@ public class AwContents implements SmartClipProvider, * @see android.webkit.WebView#goBackOrForward(int) */ public void goBackOrForward(int steps) { - if (TRACE) Log.d(TAG, "goBackOrForwad=" + steps); + if (TRACE) Log.d(TAG, "goBackOrForwad=%d", steps); if (!isDestroyed(WARN)) mNavigationController.goToOffset(steps); } @@ -1867,7 +1867,7 @@ public class AwContents implements SmartClipProvider, public void saveWebArchive( final String basename, boolean autoname, final ValueCallback<String> callback) { - if (TRACE) Log.d(TAG, "saveWebArchive=" + basename); + if (TRACE) Log.d(TAG, "saveWebArchive=%s", basename); if (!autoname) { saveWebArchiveInternal(basename, callback); return; @@ -1926,7 +1926,7 @@ public class AwContents implements SmartClipProvider, public void setHttpAuthUsernamePassword(String host, String realm, String username, String password) { - if (TRACE) Log.d(TAG, "setHttpAuthUsernamePassword=" + host); + if (TRACE) Log.d(TAG, "setHttpAuthUsernamePassword=%s", host); if (isDestroyed(WARN)) return; mBrowserContext.getHttpAuthDatabase(mContext) .setHttpAuthUsernamePassword(host, realm, username, password); @@ -2119,7 +2119,7 @@ public class AwContents implements SmartClipProvider, * @see ContentViewCore.evaluateJavaScript(String, JavaScriptCallback) */ public void evaluateJavaScript(String script, final ValueCallback<String> callback) { - if (TRACE) Log.d(TAG, "evaluateJavascript=" + script); + if (TRACE) Log.d(TAG, "evaluateJavascript=%s", script); if (isDestroyed(WARN)) return; JavaScriptCallback jsCallback = null; if (callback != null) { @@ -2135,7 +2135,7 @@ public class AwContents implements SmartClipProvider, } public void evaluateJavaScriptForTests(String script, final ValueCallback<String> callback) { - if (TRACE) Log.d(TAG, "evaluateJavascriptForTests=" + script); + if (TRACE) Log.d(TAG, "evaluateJavascriptForTests=%s", script); if (isDestroyed(NO_WARN)) return; JavaScriptCallback jsCallback = null; if (callback != null) { @@ -2186,7 +2186,7 @@ public class AwContents implements SmartClipProvider, @Override public void postMessageToWeb(String frameName, String message, String targetOrigin, int[] sentPortIds) { - if (TRACE) Log.d(TAG, "postMessageToWeb. TargetOrigin=" + targetOrigin); + if (TRACE) Log.d(TAG, "postMessageToWeb. TargetOrigin=%s", targetOrigin); if (isDestroyed(NO_WARN)) return; nativePostMessageToFrame(mNativeAwContents, frameName, message, targetOrigin, sentPortIds); @@ -2258,7 +2258,7 @@ public class AwContents implements SmartClipProvider, if (requestCode == PROCESS_TEXT_REQUEST_CODE) { mContentViewCore.onReceivedProcessTextResult(resultCode, data); } else { - Log.e(TAG, "Received activity result for an unknown request code " + requestCode); + Log.e(TAG, "Received activity result for an unknown request code %d", requestCode); } } @@ -2460,7 +2460,7 @@ public class AwContents implements SmartClipProvider, */ @SuppressLint("NewApi") // JavascriptInterface requires API level 17. public void addJavascriptInterface(Object object, String name) { - if (TRACE) Log.d(TAG, "addJavascriptInterface=" + name); + if (TRACE) Log.d(TAG, "addJavascriptInterface=%s", name); if (isDestroyed(WARN)) return; Class<? extends Annotation> requiredAnnotation = null; if (mAppTargetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN_MR1) { @@ -2473,7 +2473,7 @@ public class AwContents implements SmartClipProvider, * @see android.webkit.WebView#removeJavascriptInterface(String) */ public void removeJavascriptInterface(String interfaceName) { - if (TRACE) Log.d(TAG, "removeJavascriptInterface=" + interfaceName); + if (TRACE) Log.d(TAG, "removeJavascriptInterface=%s", interfaceName); if (!isDestroyed(WARN)) mContentViewCore.removeJavascriptInterface(interfaceName); } @@ -2524,7 +2524,7 @@ public class AwContents implements SmartClipProvider, } public void setNetworkAvailable(boolean networkUp) { - if (TRACE) Log.d(TAG, "setNetworkAvailable=" + networkUp); + if (TRACE) Log.d(TAG, "setNetworkAvailable=%s", networkUp); if (!isDestroyed(WARN)) nativeSetJsOnlineProperty(mNativeAwContents, networkUp); } @@ -2829,7 +2829,7 @@ public class AwContents implements SmartClipProvider, if (!new File(testName).exists()) return testName; } - Log.e(TAG, "Unable to auto generate archive name for path: " + baseName); + Log.e(TAG, "Unable to auto generate archive name for path: %s", baseName); return null; } diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java index 47d0f28..e1a8ac3 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java @@ -41,7 +41,7 @@ import java.util.HashMap; * i.e.: all methods in this class should either be final, or abstract. */ public abstract class AwContentsClient { - private static final String TAG = "cr.AwContentsClient"; + private static final String TAG = "AwContentsClient"; private final AwContentsClientCallbackHelper mCallbackHelper; // Last background color reported from the renderer. Holds the sentinal value INVALID_COLOR @@ -174,7 +174,7 @@ public abstract class AwContentsClient { private static boolean sendBrowsingIntent(Context context, String url, boolean hasUserGesture, boolean isRedirect) { if (!hasUserGesture && !isRedirect) { - Log.w(TAG, "Denied starting an intent without a user gesture, URI " + url); + Log.w(TAG, "Denied starting an intent without a user gesture, URI %s", url); return true; } Intent intent; @@ -182,7 +182,7 @@ public abstract class AwContentsClient { try { intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); } catch (Exception ex) { - Log.w(TAG, "Bad URI " + url, ex); + Log.w(TAG, "Bad URI %s", url, ex); return false; } // Sanitize the Intent, ensuring web pages can not bypass browser @@ -202,7 +202,7 @@ public abstract class AwContentsClient { try { context.startActivity(intent); } catch (ActivityNotFoundException ex) { - Log.w(TAG, "No application can handle " + url); + Log.w(TAG, "No application can handle %s", url); return false; } |