Repository navigation
fix(color): reject signed hex digits in GetColor - #1230
Kernel-Hunter wants to merge 1 commit into
Conversation
GetColor("#-00001") parsed the sign and returned a corrupted color. ParseUint rejects signs, so such strings now give Default.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1230 +/- ##
==========================================
+ Coverage 91.94% 92.02% +0.08%
==========================================
Files 49 49
Lines 6145 6145
==========================================
+ Hits 5650 5655 +5
+ Misses 478 473 -5
Partials 17 17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
color.GetColorparses the six hex digits withstrconv.ParseInt, which accepts a leading sign. SoGetColor("#-00001")returns 0xffffffff andGetColor("#+00001")returns a color with the validity bits set and the red channel at 0. Neither is a hex color, they should be Default like any other bad string.ParseUintdoesn't take a sign, so the fix is a one-word change. Test added in color/color_test.go; it fails on main and passes now, andgo test ./...is green.Summary by CodeRabbit
#RRGGBBformat can now be parsed correctly when their hexadecimal value exceeds the signed 32-bit range.