diff --git a/novel-common/pom.xml b/novel-common/pom.xml index 67f7265..248fcf2 100644 --- a/novel-common/pom.xml +++ b/novel-common/pom.xml @@ -5,7 +5,7 @@ novel com.java2nb - 2.0.0 + 2.0.1 4.0.0 diff --git a/novel-crawl/pom.xml b/novel-crawl/pom.xml index c7ef362..d868199 100644 --- a/novel-crawl/pom.xml +++ b/novel-crawl/pom.xml @@ -5,7 +5,7 @@ novel com.java2nb - 2.0.0 + 2.0.1 4.0.0 diff --git a/novel-front/pom.xml b/novel-front/pom.xml index 66b7612..ef43731 100644 --- a/novel-front/pom.xml +++ b/novel-front/pom.xml @@ -5,7 +5,7 @@ novel com.java2nb - 2.0.0 + 2.0.1 4.0.0 diff --git a/novel-front/src/main/java/com/java2nb/novel/controller/UserController.java b/novel-front/src/main/java/com/java2nb/novel/controller/UserController.java index 887e8c5..b37c5ca 100644 --- a/novel-front/src/main/java/com/java2nb/novel/controller/UserController.java +++ b/novel-front/src/main/java/com/java2nb/novel/controller/UserController.java @@ -234,6 +234,12 @@ public class UserController extends BaseController { return ResultBean.fail(ResponseStatus.NO_LOGIN); } userService.updateUserInfo(userDetails.getId(),user); + if(user.getNickName() != null){ + userDetails.setNickName(user.getNickName()); + Map data = new HashMap<>(1); + data.put("token", jwtTokenUtil.generateToken(userDetails)); + return ResultBean.ok(data); + } return ResultBean.ok(); } diff --git a/novel-front/src/main/java/com/java2nb/novel/core/wrapper/XssHttpServletRequestWrapper.java b/novel-front/src/main/java/com/java2nb/novel/core/wrapper/XssHttpServletRequestWrapper.java index 059e265..b56f7fa 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/wrapper/XssHttpServletRequestWrapper.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/wrapper/XssHttpServletRequestWrapper.java @@ -1,37 +1,42 @@ package com.java2nb.novel.core.wrapper; +import org.apache.commons.lang3.StringUtils; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; +import java.util.Arrays; +import java.util.List; /** * XSS过滤处理 + * * @author Administrator */ -public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper -{ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { + + /** + * 假如有有html 代码是自己传来的 需要设定对应的name 不过滤 + */ + private static final List noFilterNames = Arrays.asList("content"); + /** * @param request */ - public XssHttpServletRequestWrapper(HttpServletRequest request) - { + public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); } @Override - public String[] getParameterValues(String name) - { + public String[] getParameterValues(String name) { String[] values = super.getParameterValues(name); - if (values != null) - { + if (!noFilterNames.contains(name) && values != null) { int length = values.length; String[] escapseValues = new String[length]; - for (int i = 0; i < length; i++) - { - // 防xss攻击和过滤前后空格 - escapseValues[i] = values[i].replaceAll("<","<").replaceAll(">",">"); + for (int i = 0; i < length; i++) { + escapseValues[i] = values[i].replaceAll("<", "<").replaceAll(">", ">"); } return escapseValues; } - return super.getParameterValues(name); + return values; } } diff --git a/novel-front/src/main/resources/application.yml b/novel-front/src/main/resources/application.yml index 9ab7ea8..2303787 100644 --- a/novel-front/src/main/resources/application.yml +++ b/novel-front/src/main/resources/application.yml @@ -23,7 +23,7 @@ xss: # 排除链接(多个用逗号分隔) excludes: /system/notice/* # 匹配链接 (多个用逗号分隔) - urlPatterns: /book/addBookComment,/user/addFeedBack + urlPatterns: /book/addBookComment,/user/addFeedBack,/author/addBook,/author/addBookContent,/author/register.html diff --git a/novel-front/src/main/resources/templates/book/book_content.html b/novel-front/src/main/resources/templates/book/book_content.html index 5e8cc54..3f33237 100644 --- a/novel-front/src/main/resources/templates/book/book_content.html +++ b/novel-front/src/main/resources/templates/book/book_content.html @@ -2,7 +2,7 @@ - + @@ -74,7 +74,7 @@
@@ -82,11 +82,11 @@
-

+

类别: - 作者: + 作者:
diff --git a/novel-front/src/main/resources/templates/book/book_detail.html b/novel-front/src/main/resources/templates/book/book_detail.html index 248e471..70e5cc0 100644 --- a/novel-front/src/main/resources/templates/book/book_detail.html +++ b/novel-front/src/main/resources/templates/book/book_detail.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - +
@@ -31,8 +31,8 @@ th:attr="alt=${book.bookName}"/>
-

+

  • 类别: @@ -70,7 +70,7 @@
  • - +
  • @@ -143,7 +143,7 @@
    签约作家

    + th:utext="${book.authorName}">
diff --git a/novel-front/src/main/resources/templates/book/book_index.html b/novel-front/src/main/resources/templates/book/book_index.html index c6146a1..907257a 100644 --- a/novel-front/src/main/resources/templates/book/book_index.html +++ b/novel-front/src/main/resources/templates/book/book_index.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + @@ -17,7 +17,7 @@
@@ -26,11 +26,11 @@
-

+

  • - 作者: + 作者: 类别: 状态:连载中已完结 @@ -45,9 +45,9 @@ diff --git a/novel-front/src/main/resources/templates/common/footer.html b/novel-front/src/main/resources/templates/common/footer.html index 3b5c15d..6fef686 100644 --- a/novel-front/src/main/resources/templates/common/footer.html +++ b/novel-front/src/main/resources/templates/common/footer.html @@ -2,7 +2,7 @@
    - +
    diff --git a/novel-front/src/main/resources/templates/mobile/book/book_detail.html b/novel-front/src/main/resources/templates/mobile/book/book_detail.html index 51cb348..a006d2e 100644 --- a/novel-front/src/main/resources/templates/mobile/book/book_detail.html +++ b/novel-front/src/main/resources/templates/mobile/book/book_detail.html @@ -3,7 +3,7 @@ - + @@ -121,7 +121,7 @@
    - +
    @@ -133,7 +133,7 @@
    -
    +
    更新:
    diff --git a/novel-front/src/main/resources/templates/mobile/book/book_index.html b/novel-front/src/main/resources/templates/mobile/book/book_index.html index 77f797e..f1a96d1 100644 --- a/novel-front/src/main/resources/templates/mobile/book/book_index.html +++ b/novel-front/src/main/resources/templates/mobile/book/book_index.html @@ -5,7 +5,7 @@ - + @@ -48,7 +48,7 @@
    - +
    @@ -63,7 +63,7 @@

    - +

    diff --git a/novel-front/src/main/resources/templates/user/set_name.html b/novel-front/src/main/resources/templates/user/set_name.html index 1b8f79d..023cbd4 100644 --- a/novel-front/src/main/resources/templates/user/set_name.html +++ b/novel-front/src/main/resources/templates/user/set_name.html @@ -1,4 +1,5 @@ - + @@ -24,21 +25,26 @@
    -
    - -
    +
    + +
    -
    +
    - - -
    -
      -
    • 我的昵称
    • -
    •  用户名只能包括汉字、英文字母、数字和下划线
    • -
    •  
    • -
    •  
    • -
    + + +
    +
      +
    • 我的昵称
    • +
    •  用户名只能包括汉字、英文字母、数字和下划线
    • +
    •  
    • +
    •  
    • +
    @@ -57,14 +63,13 @@ dataType: "json", success: function (data) { if (data.code == 200) { - if(data.data.nickName){ + if (data.data.nickName) { $("#txtNiceName").val(data.data.nickName); - }else{ + } else { $("#txtNiceName").val(data.data.username); } - } else if (data.code == 1001) { //未登录 location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href); @@ -78,23 +83,26 @@ layer.alert('网络异常'); } }) + function updateName() { var nickname = $("#txtNiceName").val(); - if(nickname.isBlank()){ + if (nickname.isBlank()) { $("#LabErr").html("昵称不能为空!"); return; } - if(!nickname.isNickName()){ + if (!nickname.isNickName()) { $("#LabErr").html("昵称格式不正确!"); return; } $.ajax({ type: "POST", url: "/user/updateUserInfo", - data: {'nickName':nickname}, + data: {'nickName': nickname}, dataType: "json", success: function (data) { if (data.code == 200) { + + $.cookie('Authorization', data.data.token, {path: '/'}); window.location.href = '/user/setup.html'; } else if (data.code == 1001) { diff --git a/pom.xml b/pom.xml index e68ba75..62a1949 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.java2nb novel - 2.0.0 + 2.0.1 novel-common novel-front