Skip to content

🐛 Bug: 메세지 줄내림이 없어지는 현상#146

Merged
aahreum merged 4 commits intomainfrom
fix/message-card
Oct 13, 2025
Merged

🐛 Bug: 메세지 줄내림이 없어지는 현상#146
aahreum merged 4 commits intomainfrom
fix/message-card

Conversation

@aahreum
Copy link
Member

@aahreum aahreum commented Oct 13, 2025

🔗 이슈 번호

✨ 작업한 내용

image
  • 메세지 카드 가독성 문제 해결하였습니다
  • 텍스트 에디터에서 적용한 스타일도 보여지면 좋을 것 같아서 추가했습니다.

💁 Review Point

  • 수정사항 있으시면 말씀해주세요!

@vercel
Copy link

vercel bot commented Oct 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
frontend Ready Ready Preview Comment Oct 13, 2025 3:59am

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aahreum, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 메시지 카드에서 텍스트 에디터로 작성된 내용의 줄바꿈 및 서식이 사라지는 버그를 해결합니다. sanitizeConfig.js 파일의 SANITIZE_CONFIG_MESSAGECARD 설정을 업데이트하여 p, br, ol, ul, li, span 태그와 class, style 속성을 허용함으로써, 메시지 내용이 작성된 의도대로 정확하게 렌더링되도록 개선했습니다.

Highlights

  • 메시지 카드 가독성 개선: 메시지 카드에서 줄바꿈 및 텍스트 에디터에서 적용된 다양한 스타일(단락, 목록 등)이 올바르게 표시되도록 허용된 HTML 태그와 속성을 확장했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🎉 구현한 기능 Preview: https://frontend-jeadxtbyj-fe-19-seongihuns-projects.vercel.app

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 PR은 메시지 카드에서 텍스트 줄바꿈이 사라지는 버그를 수정하고, 텍스트 에디터에서 적용된 스타일이 메시지 카드에 표시되도록 개선하는 내용을 담고 있습니다. dompurify 설정을 변경하여 더 많은 HTML 태그와 속성을 허용하도록 하셨네요. 버그 수정과 기능 개선 방향은 좋지만, style 속성을 허용하면서 발생할 수 있는 보안 위험에 대한 검토가 필요해 보입니다. 이에 대한 의견을 리뷰 코멘트로 남겼습니다.

Comment on lines +32 to +33
ALLOWED_TAGS: ['p', 'br', 'ol', 'ul', 'li', 'span', 'img'],
ALLOWED_ATTR: ['src', 'alt', 'class', 'style'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

메시지 카드에서 줄바꿈과 텍스트 스타일이 유지되도록 ALLOWED_TAGSALLOWED_ATTR을 수정한 것은 좋은 접근입니다.

하지만 style 속성을 허용하는 것은 잠재적인 XSS(Cross-Site Scripting) 공격의 위험을 높일 수 있습니다. DOMPurify가 대부분의 위험한 CSS를 제거해주지만, 보안을 위해서는 허용하는 범위를 최소한으로 유지하는 것이 가장 좋습니다. 예를 들어, style 속성을 통해 UI를 덮어쓰거나 사용자를 속이는 등의 공격이 가능할 수 있습니다.

Quill 에디터에서 사용하는 color, background-color, text-align 등의 특정 스타일만 필요한 경우, 해당 속성들만 명시적으로 허용하는 것이 더 안전합니다. DOMPurify는 이 기능을 직접 지원하지 않지만, addHook을 사용하여 style 속성을 직접 파싱하고 안전하다고 판단되는 CSS 속성만 남기는 방식으로 구현할 수 있습니다.

이 변경은 보안에 영향을 줄 수 있으므로, 허용되는 스타일을 최소화하는 방향으로 재고해보시는 것을 권장합니다.

@aahreum
Copy link
Member Author

aahreum commented Oct 13, 2025

/gemini review

@github-actions
Copy link

🎉 구현한 기능 Preview: https://frontend-6e5hkgj2d-fe-19-seongihuns-projects.vercel.app

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 메시지 카드에서 줄 바꿈 및 기타 서식이 사라지는 문제를 해결하기 위해 DOMPurify의 살균 설정을 업데이트합니다. 텍스트 에디터에서 적용된 스타일이 메시지 카드에 올바르게 표시되도록 허용되는 태그와 속성을 확장하고, style 속성에 허용되는 CSS 속성을 필터링하기 위한 DOMPurify 훅을 추가했습니다.

전반적으로 변경 사항은 올바르지만, 한 가지 버그와 한 가지 개선점을 발견했습니다. 자세한 내용은 개별 코드 리뷰 댓글을 확인해주세요.

.map(([k, v]) => `${k}: ${v}`)
.join('; ');
if (!data.attrValue) {
delete node.style;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

style 속성을 제거하기 위해 delete node.style을 사용하는 것은 올바르지 않으며, 예상대로 동작하지 않을 수 있습니다. node.styleCSSStyleDeclaration 객체이며, delete 연산자로 DOM 요소의 속성을 제거할 수 없습니다.

속성을 제거하려면 node.removeAttribute('style')을 사용해야 합니다. 이렇게 수정하면 허용되지 않는 스타일만 포함된 경우 style 속성이 완전히 제거됩니다.

Suggested change
delete node.style;
node.removeAttribute('style');

Comment on lines +38 to +62
DOMPurify.addHook('uponSanitizeAttribute', (node, data) => {
if (data.attrName === 'style') {
const allowedStyles = [
'color',
'background-color',
'text-align',
'font-weight',
'font-style',
'text-decoration',
];
const styleObj = {};
data.attrValue.split(';').forEach((item) => {
const [key, value] = item.split(':').map((s) => s?.trim());
if (key && value && allowedStyles.includes(key.toLowerCase())) {
styleObj[key] = value;
}
});
data.attrValue = Object.entries(styleObj)
.map(([k, v]) => `${k}: ${v}`)
.join('; ');
if (!data.attrValue) {
delete node.style;
}
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

DOMPurify.addHook을 사용하여 훅을 등록하면 이 훅은 전역적으로 적용됩니다. 즉, 이 모듈(sanitizeConfig.js)이 임포트되는 순간부터 애플리케이션의 모든 DOMPurify.sanitize() 호출에 영향을 미치게 됩니다. 이는 DOMPurify 라이브러리의 설계이긴 하지만, 의도치 않은 부작용을 일으킬 수 있습니다.

예를 들어, 다른 곳에서 style 속성을 다른 방식으로 처리해야 하는 경우 이 전역 훅이 문제를 일으킬 수 있습니다.

이러한 전역 설정은 애플리케이션의 진입점(entry point)이나 초기화 파일과 같은 한 곳에서 명시적으로 관리하는 것을 고려해볼 수 있습니다. 만약 현재 구조를 유지한다면, 이 파일이 DOMPurify의 전역 동작을 수정한다는 것을 명확히 알리는 주석을 추가하는 것이 좋습니다.

예시 주석:

// DOMPurify의 전역 훅을 설정합니다.
// 이 훅은 애플리케이션 전체의 'style' 속성 살균에 영향을 줍니다.
DOMPurify.addHook('uponSanitizeAttribute', (node, data) => {
// ...

@github-actions
Copy link

🎉 구현한 기능 Preview: https://frontend-bw332g3gu-fe-19-seongihuns-projects.vercel.app

Copy link

@eunji0124 eunji0124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다

@aahreum aahreum merged commit d41feed into main Oct 13, 2025
3 checks passed
@aahreum aahreum deleted the fix/message-card branch October 13, 2025 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

[🐛 Bug] 메세지 줄내림이 없어지는 현상

2 participants