You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb59096
Browse filesBrowse the repository at this point in the historyBrowse files
Python: fix: decode entities once in ChatHistory.from_rendered_prompt (#14624)
### Summary
Fixes#14619
The XML parser in `ChatHistory.from_rendered_prompt` already decodes
XML/HTML entities when parsing element text. Running an additional
`html.unescape` on the parsed text caused double-decoding (e.g. `&`
became `&` on the first decode and then unescaped again, altering user
input containing literal entity representations such as `What does &
mean in HTML?`).
### Changes
1. Removed the redundant second `unescape` on parsed element text in:
- `ChatHistory.from_rendered_prompt`
- `ChatMessageContent.from_element`
- `ReasoningContent.from_element`
- `TextContent.from_element`
2. Added CDATA pre-handling to decode CDATA content once before XML
parsing so that CDATA sections remain properly decoded.
3. Added comprehensive test coverage in `test_chat_history.py` verifying
single-decode semantics across messages, plain inputs, text after
message tags, CDATA sections, and prompt round-tripping.
### Verification
- `uv run pytest tests/unit/contents/` (414 passed).
- `uv run ruff check semantic_kernel/contents/ tests/unit/contents/`
(all checks passed).
Co-authored-by: VANDRANKI <[email protected]>
0 commit comments