generated from kgod/ai-review-template
自内部仓库剥离深度优化与 RAG 知识库后的交付版本: - Builder 对话式简历生成(FSM + 意图路由 LLM 兜底增强) - 条目级轻度优化:事实覆盖门禁 + STAR/bullet 修复链,功能/简介/成果与技术栈同级保护 - 简历导入:DOCX/PDF 解析、结构归一、手机号脱敏 - PostgreSQL 运行时 + Alembic 迁移链 Co-Authored-By: Claude <noreply@anthropic.com>
26 lines
918 B
Python
26 lines
918 B
Python
"""Small display-text normalizers for model and persisted proposal content."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from typing import Any
|
|
|
|
|
|
_LITERAL_UNICODE_ESCAPE = re.compile(r"(?<!\\)\\u([0-9a-fA-F]{4})")
|
|
|
|
|
|
def decode_literal_unicode_escapes(value: Any) -> Any:
|
|
"""Decode only literal ``\\uXXXX`` sequences accidentally returned as text.
|
|
|
|
JSON parsing normally handles Unicode escapes. This is deliberately narrow so a
|
|
user-entered path or other ordinary backslash content is not reinterpreted.
|
|
"""
|
|
if isinstance(value, str):
|
|
return _LITERAL_UNICODE_ESCAPE.sub(
|
|
lambda match: chr(int(match.group(1), 16)), value
|
|
)
|
|
if isinstance(value, list):
|
|
return [decode_literal_unicode_escapes(item) for item in value]
|
|
if isinstance(value, dict):
|
|
return {key: decode_literal_unicode_escapes(item) for key, item in value.items()}
|
|
return value |