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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java

Issue 23566019: Adding range checking to setSelection and setComposingRegion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
index 4929c6afcbc6beae479ef4da034333dea676291f..7d39b7fba1618f997f188a46dfc819aedd247b83 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
@@ -372,8 +372,9 @@ public class AdapterInputConnection extends BaseInputConnection {
*/
@Override
public boolean setSelection(int start, int end) {
- if (DEBUG) Log.w(TAG, "setSelection");
- if (start < 0 || end < 0) return true;
+ if (DEBUG) Log.w(TAG, "setSelection [" + start + " " + end + "]");
+ int textLength = getEditable().length();
+ if (start < 0 || end < 0 || start > textLength || end > textLength) return true;
super.setSelection(start, end);
return mImeAdapter.setEditableSelectionOffsets(start, end);
}
@@ -395,10 +396,13 @@ public class AdapterInputConnection extends BaseInputConnection {
@Override
public boolean setComposingRegion(int start, int end) {
if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + "]");
+ int textLength = getEditable().length();
int a = Math.min(start, end);
int b = Math.max(start, end);
if (a < 0) a = 0;
if (b < 0) b = 0;
+ if (a > textLength) a = textLength;
+ if (b > textLength) b = textLength;
if (a == b) {
removeComposingSpans(getEditable());
« 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