Skip to content

Escape mermaid-export theme and background color - #14

Merged
arnelirobles merged 3 commits into
mainfrom
fix/mermaid-export-escape
Nov 12, 2026
Merged

arnelirobles merged 3 commits into
mainfrom
fix/mermaid-export-escape

Conversation

@arnelirobles

Copy link
Copy Markdown
Contributor

Escapes theme and backgroundColor before they go into the render page (JSON string for the script, hex escapes for CSS) and rejects any theme outside the union at runtime. The HTML builder moved to src/html.ts so it can be tested without Chrome. README now says diagrams and options must be trusted, and documents --no-sandbox and securityLevel.

Not changed, these are design decisions: the --no-sandbox default and the securityLevel: 'loose' default.

Tests: src/html.test.ts (7 tests, no Chrome needed, run locally and green).

- test: packages/mermaid-export/src/html.test.ts
  breaks: packages/mermaid-export/src/html.ts "theme: ${escapeJsString(theme)},"
- test: packages/mermaid-export/src/html.test.ts
  breaks: packages/mermaid-export/src/html.ts "background-color: ${escapeCss(backgroundColor)};"
- test: packages/mermaid-export/src/html.test.ts
  breaks: packages/mermaid-export/src/renderer.ts "validateTheme(theme);"

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2988897e-58da-4c99-b6d7-010208300bec
Commits

Reviewing files that changed from the base of the PR and between 1eed13a and aecd965.

Files selected for processing: 5

  • .changeset/mermaid-export-escape.md
  • packages/mermaid-export/README.md
  • packages/mermaid-export/src/html.test.ts
  • packages/mermaid-export/src/html.ts
  • packages/mermaid-export/src/renderer.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@arnelirobles
arnelirobles marked this pull request as ready for review November 12, 2026 15:36
@arnelirobles
arnelirobles merged commit 018cd2f into main Nov 12, 2026
2 checks passed
@arnelirobles
arnelirobles deleted the fix/mermaid-export-escape branch November 12, 2026 15:36
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