зеркало из https://github.com/mozilla/pjs.git
Bug 765831 - Part 4: Clamp string lengths passed to getTextBeforeCursor/getTextAfterCursor. r=blassey
This commit is contained in:
Родитель
780e0bee1d
Коммит
3fa12648e8
|
@ -256,7 +256,16 @@ public class GeckoInputConnection
|
|||
|
||||
@Override
|
||||
public CharSequence getTextBeforeCursor(int length, int flags) {
|
||||
clampSelection();
|
||||
// Avoid underrunning text buffer.
|
||||
Span selection = clampSelection();
|
||||
if (length > selection.start) {
|
||||
length = selection.start;
|
||||
}
|
||||
|
||||
if (length < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return super.getTextBeforeCursor(length, flags);
|
||||
}
|
||||
|
||||
|
@ -268,7 +277,17 @@ public class GeckoInputConnection
|
|||
|
||||
@Override
|
||||
public CharSequence getTextAfterCursor(int length, int flags) {
|
||||
clampSelection();
|
||||
// Avoid overrunning text buffer.
|
||||
Span selection = clampSelection();
|
||||
int contentLength = getEditable().length();
|
||||
if (selection.end + length > contentLength) {
|
||||
length = contentLength - selection.end;
|
||||
}
|
||||
|
||||
if (length < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return super.getTextAfterCursor(length, flags);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче