Skip to content

Commit

Permalink
修复获取网页title时的数组越界问题
Browse files Browse the repository at this point in the history
  • Loading branch information
KingsFish committed Nov 6, 2019
1 parent 3f8d908 commit 15c41c5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/src/main/java/me/yluo/ruisiapp/activity/PostActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,17 @@ protected List<SingleArticleData> doInBackground(String... params) {
if (!isGetTitle) {
int ih = htmlData.indexOf("keywords");
if (ih > 0) {
int hStart = htmlData.indexOf('\"', ih + 15);
int hEnd = htmlData.indexOf('\"', hStart + 1);
title = htmlData.substring(hStart + 1, hEnd);
isGetTitle = true;
try {
int hStart = htmlData.indexOf('\"', ih + 15);
int hEnd = htmlData.indexOf('\"', hStart + 1);
title = htmlData.substring(hStart + 1, hEnd);
isGetTitle = true;
} catch (Exception e) {
// substring时可能出现indexOutOfBoundException
// 无法访问内网,暂时这样处理
title = "浏览帖子";
isGetTitle = true;
}
}
}

Expand Down

0 comments on commit 15c41c5

Please sign in to comment.