Skip to content

fix(ui): XSS, state mutation, and miscellaneous frontend fixes#1927

Open
HandSonic wants to merge 3 commits into
OtterMind:mainfrom
HandSonic:fix/frontend-fixes
Open

fix(ui): XSS, state mutation, and miscellaneous frontend fixes#1927
HandSonic wants to merge 3 commits into
OtterMind:mainfrom
HandSonic:fix/frontend-fixes

Conversation

@HandSonic

Copy link
Copy Markdown
Contributor

Summary

Fixes 7 verified frontend bugs.

Fixes included:

  • XSS in tree search: escapes HTML entities before dangerouslySetInnerHTML to prevent stored XSS via database object names
  • Chat store state mutation: all actions now use spread operators for immutable updates instead of mutating state in-place, fixing stale renders
  • errorLevel race condition: uses local effectiveErrorLevel variable instead of mutating shared closure variable
  • useSqlExecutor onlyOne: returns [data[0]] (array) instead of data[0] (single object), matching declared return type
  • AIChatInput useEffect: adds mainPageActiveTab to dependency array so cascader data updates when switching pages
  • SSE parsing: skips lines without colon separator instead of throwing, handling malformed SSE events gracefully

dangerouslySetInnerHTML rendered unescaped nodeData.originalTitle directly.
Database object names containing HTML tags (e.g. <script>) would execute.
Now escapes HTML entities before regex replacement.
Multiple actions (appendChatDetails, updateQuestionId, appendAnswerParts,
stopAllAnswerParts, updateAnswer) mutated state objects in-place then
called set() with the same reference. Zustand's equality check cannot
detect changes on the same object reference, causing React components
to not re-render. Now uses spread operators to create new objects.
… parsing

- base.tsx: use local effectiveErrorLevel variable instead of mutating
  shared closure variable, preventing concurrent request race condition
- useSqlExecutor: onlyOne=true now returns [data[0]] (array) instead of
  data[0] (single object), matching the declared return type
- AIChatInput: add mainPageActiveTab to useEffect dependency array so
  cascader data updates when switching pages
- sseStream: skip lines without colon separator instead of throwing,
  handling malformed SSE events gracefully
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.

1 participant