diff options
author | Henrik Hall <henrik.hall@sonyericsson.com> | 2010-03-26 15:32:48 +0100 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonyericsson.com> | 2010-03-26 15:32:48 +0100 |
commit | 9694f9056a86081aadc1d7caab82d340847b3884 (patch) | |
tree | a26ac41450146c637a1cd1503915905aef062773 /core/java/android/text | |
parent | 7bb2581e6f404da0edba9ebb81b0d0593715eb40 (diff) | |
download | frameworks_base-9694f9056a86081aadc1d7caab82d340847b3884.zip frameworks_base-9694f9056a86081aadc1d7caab82d340847b3884.tar.gz frameworks_base-9694f9056a86081aadc1d7caab82d340847b3884.tar.bz2 |
Improved error-handling in Rfc822Tokenizer
The javadoc for the Rfc822Tokenizer states that it will try
to be tolerant to broken syntax instead of returning an error
(as in an unchecked exception). In some rare cases where the
input is clearly incorrect, the tokenizer throws a
StringIndexOutOfBoundsException, which was found during
one of the monkey test runs. This commits fixes that crash,
and teaches the tokenizer to just continue to run anyway. Two
simple junit testcases has also been added for testing the
default and the errornous case.
Diffstat (limited to 'core/java/android/text')
-rw-r--r-- | core/java/android/text/util/Rfc822Tokenizer.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/java/android/text/util/Rfc822Tokenizer.java b/core/java/android/text/util/Rfc822Tokenizer.java index cb39f7d..3a67e20 100644 --- a/core/java/android/text/util/Rfc822Tokenizer.java +++ b/core/java/android/text/util/Rfc822Tokenizer.java @@ -86,7 +86,9 @@ public class Rfc822Tokenizer implements MultiAutoCompleteTextView.Tokenizer { i++; break; } else if (c == '\\') { - name.append(text.charAt(i + 1)); + if (i + 1 < cursor) { + name.append(text.charAt(i + 1)); + } i += 2; } else { name.append(c); @@ -112,7 +114,9 @@ public class Rfc822Tokenizer implements MultiAutoCompleteTextView.Tokenizer { level++; i++; } else if (c == '\\') { - comment.append(text.charAt(i + 1)); + if (i + 1 < cursor) { + comment.append(text.charAt(i + 1)); + } i += 2; } else { comment.append(c); |