Skip to content

Commit

Permalink
Merge pull request #1444 from TencentBlueKing/fix_text
Browse files Browse the repository at this point in the history
minor: 多行文本兼容 JSON、Markdown 格式 --story=119593627
  • Loading branch information
benero authored Oct 17, 2024
2 parents c81ab18 + 81cea22 commit 365b317
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog
## [Version: 2.7.1] - 2024-10-15
【新增】pipeline管理工具集成
修复】兼容第三方应用传递 json 内容
【新增】pipeline管理工具集成
优化】多行文本兼容 JSON、Markdown 格式

## [Version: 2.7.0] - 2024-10-10
【新增】通知人员黑名单过滤
Expand Down
4 changes: 2 additions & 2 deletions docs/RELEASE_EN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog
## [Version: 2.7.1] - 2024-10-15
【Feature】Integrated pipeline management tool.
Fix】Ensure compatibility for third-party applications transmitting JSON content.
【Feature】Integrated pipeline management tool.
Improved】Ensure TEXT compatibility with JSON and Markdown formats.


## [Version: 2.7.0] - 2024-10-10
Expand Down
5 changes: 3 additions & 2 deletions itsm/component/constants/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@
("CUSTOM_API", "自定义API"),
]

XSS_FIELD_TYPE = [
"RICHTEXT"
FIELD_IGNORE_ESCAPE = [
"FILE",
"TEXT"
]

LAYOUT_CHOICES = [
Expand Down
18 changes: 3 additions & 15 deletions itsm/ticket/models/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
BK_PLUGIN_STATE,
SUSPENDED,
SHOW_BY_CONDITION,
VARIABLE_LEADER,
VARIABLE_LEADER, FIELD_IGNORE_ESCAPE,
)
from itsm.component.constants.trigger import (
CREATE_TICKET,
Expand Down Expand Up @@ -3085,20 +3085,8 @@ def fill_state_fields(self, fields):
filter_field_query_set = self.fields.filter(key__in=fields_map.keys())
for ticket_field in filter_field_query_set:
ticket_field.value = fields_map[ticket_field.key]["value"]
if isinstance(ticket_field.value, str):
need_escape = True
# 附件不做xss处理
if ticket_field.type == "FILE":
need_escape = False
# 如果文本是 json 格式,则不额外处理
if ticket_field.type == "TEXT":
try:
json.loads(ticket_field.value)
need_escape = False
except Exception:
pass
if need_escape:
ticket_field.value = texteditor_escape(ticket_field.value)
if isinstance(ticket_field.value, str) and ticket_field.type not in FIELD_IGNORE_ESCAPE:
ticket_field.value = texteditor_escape(ticket_field.value)

ticket_field.choice = fields_map[ticket_field.key].get("choice", [])
language_config = (
Expand Down

0 comments on commit 365b317

Please sign in to comment.