Skip to content

fix(eventViewer): remove double HTML encoding of ampersands#29

Open
mecham-lynn wants to merge 8 commits intomasterfrom
feat/ES-2911-fix-ampersand-encoding
Open

fix(eventViewer): remove double HTML encoding of ampersands#29
mecham-lynn wants to merge 8 commits intomasterfrom
feat/ES-2911-fix-ampersand-encoding

Conversation

@mecham-lynn
Copy link
Contributor

@mecham-lynn mecham-lynn commented Mar 11, 2026

Summary

  • Removed jQuery HTML entity encoding ($('<div/>').text(...).html()) that caused ampersand characters to display as &amp; on the event view page
  • React already escapes text content when rendering via JSX, so the jQuery encoding step caused double-encoding

Task Reference

Changes Made

  • ui/js/components/tabs/eventViewer.jsx (line 424): Replaced $('<div/>').text(JSON.stringify(detail, null, 4)).html() with JSON.stringify(detail, null, 4)

Root Cause

The event viewer was HTML-encoding JSON payload text via jQuery before passing it to a React <pre> element. Since React auto-escapes text content in JSX expressions ({detailString}), the & characters were being escaped twice: first by jQuery (&&amp;) and then displayed literally by React.

Testing

  • Load the event view page and select an event whose payload contains & characters
  • Verify ampersands render as & (not &amp;)
  • Verify other special characters (<, >, ") still display correctly in event payloads

Checklist

  • Code follows project style
  • Self-review completed

Note

Medium Risk
Moderate risk because it changes runtime bootstrap config for Cognito/region selection and increases Lambda memory allocations, which can affect authentication behavior and cost/performance characteristics.

Overview
Fixes event payload rendering in eventViewer.jsx by removing the jQuery HTML-encoding step and rendering the raw JSON.stringify output so characters like & no longer display as &amp;.

Updates the HTML bootstrap in views/index to accept additional sources for Cognito ID and region (fallback to leo.cognito.id and leo.region). Separately bumps configured Lambda memory from 256MB to 512MB across multiple API handlers (cron/bot CRUD, event settings, logs, settings, SNS, and system endpoints), and adds new agent documentation via AGENTS.md (referenced by CLAUDE.md).

Written by Cursor Bugbot for commit 5b26c64. This will update automatically on new commits. Configure here.

…ped ampersands

The event viewer was using jQuery's $('<div/>').text(...).html() to
HTML-encode the JSON payload before rendering it in JSX. Since React
already escapes text content when rendering with {detailString}, this
caused double-encoding — ampersands appeared as &amp; instead of &.

Removed the jQuery encoding step so JSON.stringify output is passed
directly to React, which handles escaping correctly.

Task: ES-2911
The event viewer was HTML-encoding JSON payloads via jQuery and then
rendering them with React's {text} interpolation, which escapes HTML
entities a second time. This caused ampersands to display as &amp;
and also prevented S3 links from rendering as clickable <a> tags.

Switch to dangerouslySetInnerHTML so the pre-encoded HTML (with
jQuery's XSS-safe entity encoding) is rendered directly by the
browser. This fixes both the double-encoded ampersands and the
broken S3 link rendering.

Task: ES-2911
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@ch-snyk-sa
Copy link

ch-snyk-sa commented Mar 11, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

mecham-lynn and others added 6 commits March 11, 2026 14:55
…mpersands

Revert dangerouslySetInnerHTML approach in favor of a simpler fix:
just remove the jQuery .text().html() encoding and let React's
built-in JSX escaping handle XSS protection. This avoids the
fragility of dangerouslySetInnerHTML with external event data.

S3 link rendering (already broken before this change) is left as-is
since React escapes the <a> tags injected by the regex replacement.
This can be addressed separately if needed.

Task: ES-2911
Covers local dev setup, architecture, coding conventions, build/deploy,
domain context, and known gotchas for the bus-ui (Leo Botmon) project.

Task: ES-2911

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Task: ES-2911

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The view template now falls back to leo.cognito.id when CognitoId
is not injected via CloudFormation, enabling local development.

Task: ES-2911

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lity

Bundling aws-sdk into Lambda zips (required for Node 20 runtime)
increases cold start memory usage. 256MB is no longer sufficient.

Task: ES-2911

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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