Skip to content

Sanitize UI & escaping; persist edits; API tweak#8

Merged
shmukit merged 1 commit into
mainfrom
fix/qc-viewer
Jun 8, 2026
Merged

Sanitize UI & escaping; persist edits; API tweak#8
shmukit merged 1 commit into
mainfrom
fix/qc-viewer

Conversation

@uttamdeb

@uttamdeb uttamdeb commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Add input/output sanitization and escaping across draft and review UIs, improve status class handling, and make edit persistence more robust.

Add input/output sanitization and escaping across draft and review UIs, improve status class handling, and make edit persistence more robust.

Changes include:
- Backend: refine_explanation now returns a merged refined_question with detailed_explanation and model/timestamp metadata.
- UI: store pipeline config on load for DraftController use.
- Add escapeHtml and sanitizeRenderedHtml helpers to prevent XSS and strip dangerous attributes/tags from rendered HTML/Markdown.
- Escape IDs, filenames, status messages and other user-provided strings when injecting HTML to DOM.
- Normalize status-based class names via statusClassName to avoid invalid CSS classes.
- DraftController: derive paperCode from filename, use pipelineConfig default subject, and ensure safe IDs in generated cards and action buttons.
- ReviewController: escape editable fields when rendering, sanitize Markdown output before inserting into DOM, and sanitize preview content.
- saveCurrentEdits: changed to support force saves, guard against missing draft data, and only save when needed.
- Publish/refine flows now await saves; acceptAll/rejectCurrentQuestion made async and properly await publish/save operations. refineQuestion handling updated to accept either a full refined_question or fallback to updating generated_content.detailed_explanation.

These changes aim to harden the UI against XSS, ensure consistent class names, and make the save/publish/refine flows more reliable.
@uttamdeb
uttamdeb requested a review from shmukit June 7, 2026 06:32
@uttamdeb uttamdeb self-assigned this Jun 7, 2026

@shmukit shmukit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why we should approve:

  1. Critical Security Fix: Rendering unescaped strings and raw Markdown into .innerHTML left the viewer application exposed to XSS payloads through malicious document content or metadata. The sanitization additions address this risk.

  2. Eliminates Race Conditions: The change ensures that user-edited fields are actually saved to the database before subsequent actions are processed.

  3. Improves Consistency: Storing pipeline configuration and cleaning up class names prevents UI layout bugs and hardcoded fallback assumptions.

@shmukit
shmukit merged commit ba5d531 into main Jun 8, 2026
1 check passed
@shmukit
shmukit deleted the fix/qc-viewer branch June 8, 2026 07:09
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.

2 participants