Skip to content
This repository was archived by the owner on Apr 21, 2024. It is now read-only.

Commit bc4b1e3

Browse files
committed
🐛Fix: 包含<>的文字被误解析为标签
1 parent 091ce4d commit bc4b1e3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

wechatbot_client/wechat/adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ def json_to_action(cls, json_data: Any) -> Optional[ActionRequest]:
317317
try:
318318
action = ActionRequest.parse_obj(json_data)
319319
except ValidationError:
320-
log("ERROR", f"<r>action请求错误: </r>{json_data}")
320+
log("ERROR", f"<r>action请求错误: </r>{escape_tag(format(json_data))}")
321321
return None
322322
logstring = str(action.dict())
323323
if len(logstring) > 200:
324324
logstring = logstring[:200] + "..."
325-
log("SUCCESS", f"<y>收到action请求: </y>{logstring}")
325+
log("SUCCESS", f"<y>收到action请求: </y>{escape_tag(logstring)}")
326326
return action
327327

328328
@classmethod

wechatbot_client/wechat/wechat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
StatusUpdateEvent,
2525
)
2626
from wechatbot_client.typing import overrides
27-
from wechatbot_client.utils import logger_wrapper
27+
from wechatbot_client.utils import logger_wrapper, escape_tag
2828

2929
from .adapter import Adapter
3030

@@ -167,5 +167,5 @@ async def handle_evnt_msg(self, msg: Message) -> None:
167167
if event is None:
168168
log("DEBUG", "未生成合适事件")
169169
return
170-
log("SUCCESS", f"生成事件<g>[{event.__repr_name__()}]</g>:{event.dict()}")
170+
log("SUCCESS", f"生成事件<g>[{event.__repr_name__()}]</g>:{escape_tag(format(event.dict()))}")
171171
await self.handle_event(event)

0 commit comments

Comments
 (0)