f904d5935c
- 링크는 한 글자처럼 잠겨(contenteditable=false) execCommand 서식이 안 들어갔다 - 고른 범위의 링크는 링크 안쪽 span style 로 크기(글자 크기 도구)·굵기(굵게 버튼·Ctrl+B) - 링크 기본이 굵게라 보통 = font-weight: 400, 서버 desc_inline_style 이 400 만 허용 - 글자와 같이 고르면 글자에 적용된 굵기를 따름 - project.js 캐시 버전 20261030b, 브라우저·sanitize 테스트 추가 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.7 KiB
Python
52 lines
2.7 KiB
Python
"""아사나 아이콘 값 검증 · 설명란 글자 색/크기 sanitize (2026-10-08)."""
|
|
import importlib
|
|
import unittest
|
|
|
|
store = importlib.import_module("app.modules.project.store")
|
|
|
|
|
|
class ProjectIconTests(unittest.TestCase):
|
|
def test_basic_and_asana_icons_accepted(self):
|
|
self.assertEqual(store.validate_project_icon("rocket_launch"), "rocket_launch")
|
|
self.assertEqual(store.validate_project_icon("asana:rocket_launch"), "asana:rocket_launch")
|
|
|
|
def test_unknown_or_malformed_rejected(self):
|
|
for v in ("asana:", "asana:nope", "asana:asana:rocket_launch", "nope", "Asana:rocket_launch", ""):
|
|
self.assertIsNone(store.validate_project_icon(v), v)
|
|
|
|
|
|
class DescStyleTests(unittest.TestCase):
|
|
def clean(self, html):
|
|
return store.sanitize_description_html(html)
|
|
|
|
def test_color_and_allowed_size_kept(self):
|
|
out = self.clean('<span style="color: rgb(224, 62, 62); font-size: 22px">a</span><span style="color:#ABC">b</span>')
|
|
self.assertEqual(out, '<span style="color: rgb(224, 62, 62); font-size: 22px">a</span><span style="color: #abc">b</span>')
|
|
|
|
def test_link_inner_size_and_normal_weight_kept(self):
|
|
# 링크 서식(2026-10-30) — 링크 안쪽 span 의 크기·굵기 "보통"(400)만, 다른 굵기는 버림
|
|
out = self.clean('<a href="https://x.y"><span style="font-size: 18px; font-weight: 400">l</span></a>'
|
|
'<span style="font-weight: normal">a</span><span style="font-weight: 900">b</span>')
|
|
self.assertEqual(out, '<a href="https://x.y"><span style="font-size: 18px; font-weight: 400">l</span></a>'
|
|
'<span style="font-weight: 400">a</span><span>b</span>')
|
|
|
|
def test_other_declarations_and_sizes_dropped(self):
|
|
out = self.clean('<span style="background:url(javascript:x); font-size: 99px; color: red; position:fixed">a</span>')
|
|
self.assertEqual(out, "<span>a</span>")
|
|
|
|
def test_style_injection_attempts_dropped(self):
|
|
out = self.clean('<span style="color: #fff;}body{display:none">a</span>'
|
|
'<span style="color: expression(alert(1))">b</span>')
|
|
# 선언을 다시 조립하므로 "}body{…" 같은 나머지는 사라지고 검증된 색만 남는다
|
|
self.assertEqual(out, '<span style="color: #fff">a</span><span>b</span>')
|
|
|
|
def test_style_only_on_plain_span(self):
|
|
self.assertEqual(self.clean('<p style="color:#fff">a</p>'), "<p>a</p>")
|
|
self.assertEqual(self.clean('<span class="pj-mention" data-email="a@b.c" style="color:#fff">@a</span>'),
|
|
'<span class="pj-mention" data-email="a@b.c">@a</span>')
|
|
self.assertEqual(self.clean('<font color="#ff0000">a</font>'), "a")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|