Skip to content

Commit

Permalink
[CHORE] 구인글 상세 내용에는 XSS 필터 적용 제외 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekks committed May 3, 2024
1 parent 1fc44ba commit 11d7226
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package synk.meeteam.domain.recruitment.recruitment_post.dto.response;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Builder;
Expand All @@ -10,6 +11,7 @@
import synk.meeteam.domain.recruitment.recruitment_role.entity.RecruitmentRole;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.global.util.Encryption;
import synk.meeteam.global.util.UnescapedFieldSerializer;

@Builder
@Schema(name = "GetRecruitmentPostResponseDto", description = "구인글 조회 Dto")
Expand Down Expand Up @@ -59,6 +61,7 @@ public record GetRecruitmentPostResponseDto(
@Schema(description = "구인 역할", example = "")
List<GetRecruitmentRoleResponseDto> recruitmentRoles,
@Schema(description = "상세 내용", example = "안녕하세요. 저는 팀원을...")
@JsonSerialize(using = UnescapedFieldSerializer.class)
String content,
@Schema(description = "댓글, 대댓글", example = "")
List<GetCommentResponseDto> comments
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package synk.meeteam.global.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class UnescapedFieldSerializer extends JsonSerializer<String> {

@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
// HTML escaping을 하지 않고 그대로 출력
gen.writeRawValue("\"" + value + "\"");
}
}

0 comments on commit 11d7226

Please sign in to comment.