Skip to content

Improve HTML content sanitization and fix linting issues#1821

Merged
stephenegriffin merged 5 commits into
mainfrom
u/sgriffin/2047
May 29, 2026
Merged

Improve HTML content sanitization and fix linting issues#1821
stephenegriffin merged 5 commits into
mainfrom
u/sgriffin/2047

Conversation

@stephenegriffin
Copy link
Copy Markdown
Member

This pull request refactors how URLs and potentially unsafe HTML content are handled and rendered, especially in the ArchivedRow component and related UI. The main goal is to improve security by ensuring that only valid URLs are rendered as links and all other content is properly HTML-encoded. Additionally, the PR updates tests to reflect these changes and cleans up some ESLint settings.

Security and rendering improvements:

  • src/Scripts/row/ArchivedRow.ts: Replaces the generic Strings.mapValueToURL with a stricter valueUrl getter. Now, only strict angle-bracketed HTTP(S) URLs are rendered as clickable links; all other values are safely HTML-encoded, preventing executable HTML from being rendered.
  • src/Scripts/Strings.ts: Removes the now-unused mapValueToURL method.

UI updates for safe encoding:

Testing improvements:

  • src/Scripts/row/ArchivedRow.test.ts: Updates and extends tests for ArchivedRow to cover the new logic, including strict URL detection, proper encoding of potentially dangerous payloads, and RFC2047 decoding scenarios. Mocks are improved to use real implementations for encoding functions.

Tooling configuration:

  • .vscode/settings.json: Changes ESLint auto-fix on save to use the ESLint-specific fix action, aligning with best practices and preventing unintended fixes from other sources.

@stephenegriffin stephenegriffin requested a review from Copilot May 29, 2026 13:42
@stephenegriffin stephenegriffin changed the title Fix linting issues and improve HTML content sanitization Improve HTML content sanitization and fix linting issues May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 tightens how potentially unsafe header/UI content is rendered in the Outlook add-in, aiming to prevent HTML injection by encoding user-controlled values and restricting when URLs become clickable links.

Changes:

  • Updated ArchivedRow URL rendering logic to only link strict angle-bracketed HTTP(S) URLs; otherwise HTML-encode content.
  • Switched several innerHTML render paths in the iOS mobile pane to HTML-encode user-controlled values before insertion.
  • Removed the now-unused Strings.mapValueToURL helper and updated unit tests and editor ESLint-on-save configuration.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Scripts/ui/newMobilePaneIosFrame.ts Encodes user-controlled values before inserting into innerHTML in the mobile UI.
src/Scripts/Strings.ts Removes mapValueToURL helper.
src/Scripts/row/ArchivedRow.ts Refactors Archived-At rendering to validate and link only strict HTTP(S) URLs.
src/Scripts/row/ArchivedRow.test.ts Updates tests for new ArchivedRow behavior and mocking approach.
.vscode/settings.json Uses ESLint-specific fix action on save.

Comment thread src/Scripts/row/ArchivedRow.ts
Comment thread src/Scripts/row/ArchivedRow.test.ts
Comment thread src/Scripts/row/ArchivedRow.test.ts
Comment thread src/Scripts/row/ArchivedRow.test.ts
stephenegriffin and others added 2 commits May 29, 2026 09:52
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Stephen Griffin <stephenegriffin@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment thread src/Scripts/row/ArchivedRow.ts
Comment thread src/Scripts/row/ArchivedRow.test.ts
Comment thread src/Scripts/row/ArchivedRow.ts
Comment thread src/Scripts/row/ArchivedRow.test.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/Scripts/row/ArchivedRow.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Stephen Griffin <stephenegriffin@users.noreply.github.com>
@stephenegriffin stephenegriffin enabled auto-merge (squash) May 29, 2026 14:53
@stephenegriffin stephenegriffin merged commit 8cda416 into main May 29, 2026
6 checks passed
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