Repository navigation
[WEB-10190] fix: validate editor color attributes - #10309
Conversation
… 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.
|
Warning Review limit reachedYou'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. View limit details
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. |
There was a problem hiding this comment.
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.
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
sriramveeraghanta
left a comment
There was a problem hiding this comment.
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.
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.
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)
Description
Color attributes read from stored content were interpolated into inline
stylestrings without validation incustom-color.tsand the tablecell,headerandrowextensions, so a stored value could add further CSS declarations for every viewer.One shared validator,
isValidCssColor(hex,rgb()/rgba()/hsl()/hsla()with numeric arguments, orvar(--name)), now gates all four. A value that fails produces nostyle.What the pickers write still passes: text and background pickers write
COLORS_LISTkeys (no style), the table picker writesvar(--editor-colors-*-background), and older content holds 6- and 8-digit hex.Behavior change:
redare no longer written to a style.<td>no longer carriesstyle="background-color: null; color: null;"and<th>no longer carriesbackground-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 legacybackgroundattribute 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
Screenshots and Media (if applicable)
Test Scenarios
packages/editor/src/extensions/__tests__/color-attributes.test.ts: validator cases, and rendering throughgenerateHTMLwith the real schema for span,tr,thandtd. 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
Created with Claude Code