Skip to content

Commit

Permalink
修复部分画廊无法正确显示上传者评论的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojieonly committed Sep 18, 2024
1 parent 95149b5 commit 122ce51
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,11 @@ public static GalleryComment parseComment(Element element) {
// Id
Element a = element.previousElementSibling();
String name = a.attr("name");
comment.id = Integer.parseInt(StringUtils.trim(name).substring(1));
try {
comment.id = Integer.parseInt(StringUtils.trim(name).substring(1));
} catch (NumberFormatException ignore) {

}
// Editable, vote up and vote down
Element c4 = JsoupUtils.getElementByClass(element, "c4");
if (null != c4) {
Expand Down Expand Up @@ -512,10 +516,20 @@ public static GalleryComment parseComment(Element element) {
// time
Element c3 = JsoupUtils.getElementByClass(element, "c3");
String temp = c3.ownText();
temp = temp.substring("Posted on ".length(), temp.length() - " by:".length());
if (temp.contains(" by:")){
temp = temp.substring("Posted on ".length(), temp.length() - " by:".length());
}else {
temp = temp.substring("Posted on ".length());
}

comment.time = WEB_COMMENT_DATE_FORMAT.parse(temp).getTime();
// user
comment.user = c3.child(0).text();
if (c3.children().isEmpty()){
comment.user = c4.text();
}else {
comment.user = c3.child(0).text();
}

// comment
comment.comment = JsoupUtils.getElementByClass(element, "c6").html();
// last edited
Expand Down Expand Up @@ -543,7 +557,7 @@ public static GalleryCommentList parseComments(Document document) {
Element cdiv = document.getElementById("cdiv");
Elements c1s = cdiv.getElementsByClass("c1");

List<GalleryComment> list = new ArrayList<>(c1s.size());
List<GalleryComment> list = new ArrayList<>();
for (int i = 0, n = c1s.size(); i < n; i++) {
GalleryComment comment = parseComment(c1s.get(i));
if (null != comment && !EhDB.inBlackList(comment.user)) {
Expand Down

0 comments on commit 122ce51

Please sign in to comment.