fix: don't HTML-escape quotes/apostrophes in plain-text article/ticket content - #307
fix: don't HTML-escape quotes/apostrophes in plain-text article/ticket content#307snizzleorg wants to merge 1 commit into
Conversation
…t content ArticleCreate.sanitize_body (for text/plain articles) and TicketCreate.sanitize_html (title + initial article body) used html.escape()'s default quote=True, which turns ' into ' and " into ". That's meant to guard against HTML injection, but plain-text content is sent/stored verbatim by Zammad (e.g. in outbound emails), so the entities show up literally instead of being decoded. Keep escaping <, >, & for defense-in-depth, but stop escaping quotes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughUpdated ticket and article creation sanitization to preserve quotes and apostrophes while escaping HTML-sensitive characters. Model and server tests now assert the revised plain-text behavior. ChangesPlain-text sanitization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 1 minor |
🟢 Metrics 0 complexity
Metric Results Complexity 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Summary
ArticleCreate.sanitize_body(fortext/plainarticles added viazammad_add_article) andTicketCreate.sanitize_html(title + initial article body viazammad_create_ticket) both calledhtml.escape()with its defaultquote=True, which turns'into'and"into".'in the actual sent email, even thoughcontent_typeistext/plain(the default).<,>,&for defense-in-depth, but stop escaping quotes (html.escape(v, quote=False)) for plain-text content.Test plan
uv run pytest— full suite passes (222 passed)uv run ruff check/uv run mypy— cleantest_html_sanitization_in_title,test_html_sanitization_in_bodyin bothtests/test_models.pyand theArticleCreateequivalent intests/test_server.py) to assert quotes are preserved while</>remain escapedSummary by CodeRabbit