mirror of https://github.com/halo-dev/halo
parent
fae1df3859
commit
d6b3d6cb5d
|
@ -8,6 +8,7 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
import run.halo.app.cache.lock.CacheLock;
|
||||
import run.halo.app.model.dto.BaseCommentDTO;
|
||||
import run.halo.app.model.dto.JournalDTO;
|
||||
|
@ -24,6 +25,7 @@ import run.halo.app.service.JournalCommentService;
|
|||
import run.halo.app.service.JournalService;
|
||||
import run.halo.app.service.OptionService;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
@ -108,6 +110,9 @@ public class JournalController {
|
|||
@ApiOperation("Comments a post")
|
||||
@CacheLock(autoDelete = false, traceRequest = true)
|
||||
public BaseCommentDTO comment(@RequestBody JournalCommentParam journalCommentParam) {
|
||||
|
||||
// Escape content
|
||||
journalCommentParam.setContent(HtmlUtils.htmlEscape(journalCommentParam.getContent(), StandardCharsets.UTF_8.displayName()));
|
||||
return journalCommentService.convertTo(journalCommentService.createBy(journalCommentParam));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
import run.halo.app.cache.lock.CacheLock;
|
||||
import run.halo.app.model.dto.BaseCommentDTO;
|
||||
import run.halo.app.model.dto.post.BasePostSimpleDTO;
|
||||
|
@ -21,6 +22,7 @@ import run.halo.app.service.OptionService;
|
|||
import run.halo.app.service.PostCommentService;
|
||||
import run.halo.app.service.PostService;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
@ -131,6 +133,9 @@ public class PostController {
|
|||
@CacheLock(autoDelete = false, traceRequest = true)
|
||||
public BaseCommentDTO comment(@RequestBody PostCommentParam postCommentParam) {
|
||||
postCommentService.validateCommentBlackListStatus();
|
||||
|
||||
// Escape content
|
||||
postCommentParam.setContent(HtmlUtils.htmlEscape(postCommentParam.getContent(), StandardCharsets.UTF_8.displayName()));
|
||||
return postCommentService.convertTo(postCommentService.createBy(postCommentParam));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
import run.halo.app.cache.lock.CacheLock;
|
||||
import run.halo.app.model.dto.BaseCommentDTO;
|
||||
import run.halo.app.model.entity.Sheet;
|
||||
|
@ -20,6 +21,7 @@ import run.halo.app.service.OptionService;
|
|||
import run.halo.app.service.SheetCommentService;
|
||||
import run.halo.app.service.SheetService;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
@ -116,6 +118,9 @@ public class SheetController {
|
|||
@ApiOperation("Comments a post")
|
||||
@CacheLock(autoDelete = false, traceRequest = true)
|
||||
public BaseCommentDTO comment(@RequestBody SheetCommentParam sheetCommentParam) {
|
||||
|
||||
// Escape content
|
||||
sheetCommentParam.setContent(HtmlUtils.htmlEscape(sheetCommentParam.getContent(), StandardCharsets.UTF_8.displayName()));
|
||||
return sheetCommentService.convertTo(sheetCommentService.createBy(sheetCommentParam));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue