|
@@ -11,10 +11,12 @@ import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
-import org.jsoup.safety.Whitelist;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
@@ -63,6 +65,7 @@ import io.swagger.annotations.ApiParam;
|
|
|
@Api(tags = "公告类")
|
|
|
@RequestMapping("${$rmp.ctr.examwork}/notice")
|
|
|
public class NoticeController extends ControllerSupport {
|
|
|
+ private static Pattern pattern = Pattern.compile("\\s*");
|
|
|
@Autowired
|
|
|
private NoticeService noticeService;
|
|
|
|
|
@@ -243,7 +246,9 @@ public class NoticeController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
String content = addNoticeDomain.getContent();
|
|
|
- String simpleText = Jsoup.clean(content, Whitelist.simpleText());
|
|
|
+ Document doc = Jsoup.parse(content);
|
|
|
+ Matcher m = pattern.matcher(doc.text());
|
|
|
+ String simpleText = m.replaceAll("").replaceAll(" ", "");
|
|
|
// 普通文本内容不允许超过500个字
|
|
|
if (simpleText.length() > 500) {
|
|
|
throw new StatusException("500010", "通知内容不得超过500个字符");
|
|
@@ -266,8 +271,10 @@ public class NoticeController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
String content = updateNoticeDomain.getContent();
|
|
|
- String simpleText = Jsoup.clean(content, Whitelist.simpleText());
|
|
|
- // 普通文本内容不允许超过500个字 TODO 该方法待校验,因为不确定富文本框中图片的保存格式
|
|
|
+ Document doc = Jsoup.parse(content);
|
|
|
+ Matcher m = pattern.matcher(doc.text());
|
|
|
+ String simpleText = m.replaceAll("").replaceAll(" ", "");
|
|
|
+ // 普通文本内容不允许超过500个字
|
|
|
if (simpleText.length() > 500) {
|
|
|
throw new StatusException("500012", "通知内容不得超过500个字符");
|
|
|
}
|