Skip to content

MBS-10672: Fix AI chat HTML code output with XSS protection#124

Open
Barbuia wants to merge 6 commits intomainfrom
MBS-10672-Fix_AI_chat_HTML_code_output
Open

MBS-10672: Fix AI chat HTML code output with XSS protection#124
Barbuia wants to merge 6 commits intomainfrom
MBS-10672-Fix_AI_chat_HTML_code_output

Conversation

@Barbuia
Copy link
Copy Markdown
Contributor

@Barbuia Barbuia commented Mar 25, 2026

No description provided.

@Barbuia Barbuia force-pushed the MBS-10672-Fix_AI_chat_HTML_code_output branch 4 times, most recently from ed1120d to c2f9fa5 Compare March 25, 2026 10:48
@Barbuia Barbuia force-pushed the MBS-10672-Fix_AI_chat_HTML_code_output branch from 50467cc to 5ed8faf Compare March 27, 2026 01:16
@Barbuia Barbuia force-pushed the MBS-10672-Fix_AI_chat_HTML_code_output branch 3 times, most recently from e0c9f2f to bea93d3 Compare March 27, 2026 14:05
BarbuiaGmbH and others added 6 commits March 31, 2026 13:42
- Replace purify_html() with format_text(FORMAT_MOODLE) for proper sanitization
- Refactor tests to use data providers instead of individual test methods
- Remove unnecessary resetAfterTest() calls (no DB/cache changes)
- Use single quotes and PHP_EOL for string concatenation
- Add assertions for <pre> and <code> tags in code block tests
- Include <script> tags in JavaScript test input for proper XSS testing
Co-authored-by: PhMemmel <65113153+PhMemmel@users.noreply.github.com>
- Add format_text() for label and explanation fields in format_output()
- Preserve newValue unchanged for form field injection
- Refactor test structure with setUp() method
- Add comprehensive unit tests with data providers:
  - Label/explanation Markdown formatting
  - newValue preservation (HTML, scripts, code)
  - chatoutput intro/outro formatting
  - Invalid input handling
  - Missing fields handling
  - Security: script tag sanitization in chatoutput
@PhMemmel PhMemmel force-pushed the MBS-10672-Fix_AI_chat_HTML_code_output branch from 2aff8a3 to e5586bf Compare March 31, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants