Skip to content

[WEB-10190] fix: validate editor color attributes - #10309

Merged
sriramveeraghanta merged 1 commit into
previewfrom
fix/web-10190-editor-color-validation
Nov 16, 2026
Merged

sriramveeraghanta merged 1 commit into
previewfrom
fix/web-10190-editor-color-validation

Conversation

@pablohashescobar

Copy link
Copy Markdown
Member

Description

Color attributes read from stored content were interpolated into inline style strings without validation in custom-color.ts and the table cell, header and row extensions, so a stored value could add further CSS declarations for every viewer.

One shared validator, isValidCssColor (hex, rgb()/rgba()/hsl()/hsla() with numeric arguments, or var(--name)), now gates all four. A value that fails produces no style.

What the pickers write still passes: text and background pickers write COLORS_LIST keys (no style), the table picker writes var(--editor-colors-*-background), and older content holds 6- and 8-digit hex.

Behavior change:

  • Named colors such as red are no longer written to a style.
  • <td> no longer carries style="background-color: null; color: null;" and <th> no longer carries background-color: none; when no color is set. Both were invalid declarations.

Not changed: the raw attributes (data-text-color, data-background-color, background, textColor) are still emitted with the stored value. The legacy background attribute on table cells is treated by browsers as a background image URL; closing that means changing how the cell color is serialised.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • New packages/editor/src/extensions/__tests__/color-attributes.test.ts: validator cases, and rendering through generateHTML with the real schema for span, tr, th and td. Output for valid values is unchanged. Editor suite: 16 passed; the injection cases fail without the fix.

Not run in a browser. Please check manually: existing colored text and colored tables in web and on a published space.

References

  • WEB-10190

Created with Claude Code

… styles

Text, background and table colors are stored document content. A value is now written into an inline style only when it is a plain CSS color (hex, rgb()/hsl() with numeric arguments, or a var() reference to a custom property); anything else renders without a style declaration.
Copilot AI balanced review requested due to automatic review settings November 15, 2026 23:04
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

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 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews 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: 98fbf9cb-9017-4715-ac37-eb1f1006ad1f
Commits

Reviewing files that changed from the base of the PR and between 290383d and dac8a36.

Files selected for processing: 6

  • packages/editor/src/extensions/__tests__/color-attributes.test.ts
  • packages/editor/src/extensions/custom-color.ts
  • packages/editor/src/extensions/table/table-cell.ts
  • packages/editor/src/extensions/table/table-header.ts
  • packages/editor/src/extensions/table/table-row.ts
  • packages/editor/src/helpers/common.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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@makeplane

makeplane Bot commented Nov 15, 2026

Copy link
Copy Markdown

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit dac8a36.

@pablohashescobar pablohashescobar changed the title [WEB-10190] fix(security): validate editor color attributes [WEB-10190] fix: validate editor color attributes Nov 16, 2026

@sriramveeraghanta sriramveeraghanta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Picker keys, var(--editor-colors-*) and the legacy hex values still pass, and I found no way to inject CSS declarations. The raw background attr on td/tr is still emitted, as the description notes.

@sriramveeraghanta
sriramveeraghanta merged commit 77e1bf7 into preview Nov 16, 2026
15 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/web-10190-editor-color-validation branch November 16, 2026 20:23
sriramveeraghanta pushed a commit that referenced this pull request Nov 16, 2026
Text, background and table colors are stored document content. A value is now written into an inline style only when it is a plain CSS color (hex, rgb()/hsl() with numeric arguments, or a var() reference to a custom property); anything else renders without a style declaration.
Pawel-Kranzberg pushed a commit to klazwi/pi-plane that referenced this pull request Nov 18, 2026
Text, background and table colors are stored document content. A value is now written into an inline style only when it is a plain CSS color (hex, rgb()/hsl() with numeric arguments, or a var() reference to a custom property); anything else renders without a style declaration.

(cherry picked from commit cfd3dc1)
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