fix: don't use unicodeSets regex feature, fix gradient transparency#607
fix: don't use unicodeSets regex feature, fix gradient transparency#607SupertigerDev merged 1 commit intoNerimity:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaced Unicode-property based gradient color parsing with an explicit ASCII hex digit regex. Introduced a dedicated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/Markup.tsx`:
- Line 82: The current regex in Markup.tsx accepts 7-digit hex colors because it
uses {6,8}; update the hex-length part to require exact allowed lengths
(3,4,6,8) instead of a range. Replace the segment
`[a-fA-F0-9]{3,4}|[a-fA-F0-9]{6,8}` with an exact-length alternation like
`(?:[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})` in the regex
literal (the pattern assigned in Markup.tsx that starts with /^(?<colors>#...),
so malformed 7-digit hex like `#1234567` will no longer match and the fallback
behavior will work as intended.
The unicode sets / "v" flag are only supported since mid 2023; this replaces them with [a-fA-F0-9], which matches the CSS spec. https://caniuse.com/mdn-javascript_builtins_regexp_unicodesets This also fixes support for 8-character #RRGGBBAA color codes.
The unicode sets / "v" flag are only supported since mid 2023; this replaces them with
[a-fA-F0-9], which matches the CSS spec. https://caniuse.com/mdn-javascript_builtins_regexp_unicodesetsThis also fixes support for 8-character #RRGGBBAA color codes. (The length was hardcoded as 7.)
Did you test your code?
I've tested this on desktop Firefox and Chrome on mobile, as well as an older version of Chrome on desktop: 100.0.4896.88-1.1 (which was stuck on a Connecting... screen before this was fixed).
Checklist
Text/content changes support internationalization (i18n)Any new user-facing strings are properly localizedSummary by CodeRabbit