Skip to content

[Bugfix:Forum] Escape raw HTML in Markdown rendering#12480

Merged
williamjallen merged 7 commits into
Submitty:mainfrom
sushen123:fix/grade-inquiry-special-chars-12285
Apr 30, 2026
Merged

[Bugfix:Forum] Escape raw HTML in Markdown rendering#12480
williamjallen merged 7 commits into
Submitty:mainfrom
sushen123:fix/grade-inquiry-special-chars-12285

Conversation

@sushen123

@sushen123 sushen123 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Why is this Change Important & Necessary?

Fixes #12285

Special characters inside angle brackets (e.g., Node <T>, List<String>) disappear when rendered in grade inquiry posts and discussion forum posts with markdown enabled.

What is the New Behavior?

Before: Node <T> renders as Node
After: Node <T> renders as Node <T>
image

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Go to any course → Discussion Forum
  2. Click the M↓ button to enable markdown
  3. Post a message containing Node <T> or List<String>
  4. Verify the angle brackets and their content are displayed correctly
  5. Verify that backtick code spans still work (e.g., `<T>` renders in a code block)

Automated Testing & Documentation

Other information

The fix applies to both the Discussion Forum and Grade Inquiry since they share the same Markdown.vue component via RenderPost.twig i think this is enough

Raw HTML in markdown posts is now escaped (rendered as literal text), matching the server-side CommonMark behavior (html_input => 'escape' in Output.php). This is intentional, user-submitted posts should not contain raw HTML for security reasons. Users can still use markdown syntax for formatting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shared Vue Markdown renderer used by forum posts, grade inquiry posts, and the /markdown preview endpoint to prevent angle-bracketed text (e.g., Node <T>, List<String>) from being interpreted as raw HTML and disappearing in rendered output.

Changes:

  • Adjusts the KaTeX inline LaTeX Marked extension to use a dedicated custom token type with a custom renderer.
  • Adds HTML escaping for Marked html tokens so raw HTML is displayed as text (fixing the <T> disappearing case).
  • Wires the escaping behavior into the Marked instance used by Markdown.vue.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread site/vue/src/components/Markdown.vue
Comment thread site/vue/src/components/Markdown.vue
Comment thread site/vue/src/components/Markdown.vue
@sushen123

Copy link
Copy Markdown
Contributor Author

@williamjallen can you look into it

@github-actions github-actions Bot added the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Mar 28, 2026
@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.67%. Comparing base (9cd4e2f) to head (64ab804).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main   #12480   +/-   ##
=========================================
  Coverage     21.67%   21.67%           
  Complexity     9807     9807           
=========================================
  Files           268      268           
  Lines         36722    36722           
  Branches        490      490           
=========================================
  Hits           7960     7960           
  Misses        28276    28276           
  Partials        486      486           
Flag Coverage Δ
autograder 21.32% <ø> (ø)
js 2.02% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.73% <ø> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roye2 roye2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that the changes work and everything looks good. I was able to write an example of some c++ code with the angle brackets being functional. Latex still worked as well. I also tried to get an HTML <script> tag to render (security issue), but the code prevents this from happening by escaping the characters. As far as I am concerned this PR is ready to be merged!

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Apr 30, 2026
@williamjallen
williamjallen merged commit eeb13e3 into Submitty:main Apr 30, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

special characters in grade inquiry posts disappear

5 participants