Maybe fix IndexOutOfBoundsException when parsing spoiler syntax.

This commit is contained in:
Alex Ning 2020-12-01 23:53:37 +08:00
parent 8cbc24b532
commit 1b2602ac3a
4 changed files with 25 additions and 0 deletions

View File

@ -145,6 +145,11 @@ public class FullMarkdownActivity extends BaseActivity {
int start = 0; int start = 0;
boolean find = false; boolean find = false;
while (matcher.find(start)) { while (matcher.find(start)) {
if (markdownStringBuilder.length() < 4
|| matcher.start() < 0
|| matcher.end() > markdownStringBuilder.length()) {
break;
}
find = true; find = true;
markdownStringBuilder.delete(matcher.end() - 2, matcher.end()); markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2); markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);

View File

@ -279,6 +279,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
int start = 0; int start = 0;
boolean find = false; boolean find = false;
while (matcher.find(start)) { while (matcher.find(start)) {
if (markdownStringBuilder.length() < 4
|| matcher.start() < 0
|| matcher.end() > markdownStringBuilder.length()) {
break;
}
find = true; find = true;
markdownStringBuilder.delete(matcher.end() - 2, matcher.end()); markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2); markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
@ -375,6 +380,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
int start = 0; int start = 0;
boolean find = false; boolean find = false;
while (matcher.find(start)) { while (matcher.find(start)) {
if (markdownStringBuilder.length() < 4
|| matcher.start() < 0
|| matcher.end() > markdownStringBuilder.length()) {
break;
}
find = true; find = true;
markdownStringBuilder.delete(matcher.end() - 2, matcher.end()); markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2); markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);

View File

@ -136,6 +136,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
int start = 0; int start = 0;
boolean find = false; boolean find = false;
while (matcher.find(start)) { while (matcher.find(start)) {
if (markdownStringBuilder.length() < 4
|| matcher.start() < 0
|| matcher.end() > markdownStringBuilder.length()) {
break;
}
find = true; find = true;
markdownStringBuilder.delete(matcher.end() - 2, matcher.end()); markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2); markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);

View File

@ -121,6 +121,11 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
int start = 0; int start = 0;
boolean find = false; boolean find = false;
while (matcher.find(start)) { while (matcher.find(start)) {
if (markdownStringBuilder.length() < 4
|| matcher.start() < 0
|| matcher.end() > markdownStringBuilder.length()) {
break;
}
find = true; find = true;
markdownStringBuilder.delete(matcher.end() - 2, matcher.end()); markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2); markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);