normalize-color accepts functional colors with surrounding junk
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.3k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
Description
@react-native/normalize-colors fully anchors hex matchers (^…$) but not rgb/rgba/hsl/hsla/hwb. Substring matches are therefore accepted:
normalizeColor('xxrgb(1, 2, 3)yy') // => 0x010203ff (unexpected)
normalizeColor('rgba(1,2,3,0.5)extra') // => non-null (unexpected)
normalizeColor(' #fff ') // => null (hex correctly rejects)
Steps to reproduce
- Open the Snack: https://snack.expo.dev/rykV9Sq-NOSJg8KWXawiP
- Look at rows for
xxrgb(1, 2, 3)yy,rgb(1, 2, 3)yy, andrgba(1,2,3,0.5)extra - Observe non-null
processColorvalues and painted swatches (bug). Spaced hex#fffcorrectly stays null.
React Native Version
main / latest (package @react-native/normalize-colors, used by processColor)
Affected Platforms
- Runtime - Android
- Runtime - iOS
- Runtime - Web
- Other (please specify): pure JS
@react-native/normalize-colors
Output of npx @react-native-community/cli info
N/A — reproducible via Snack / unit package without a local app install.
Stacktrace or Logs
N/A (incorrect non-null return value, no crash)
MANDATORY Reproducer
https://snack.expo.dev/rykV9Sq-NOSJg8KWXawiP
Screenshots and Videos
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the functional color matchers in @react-native/normalize-colors and reproduce the listed rgb, rgba, and spaced-hex cases using the linked Snack. Done means inputs with surrounding junk return null while valid functional colors continue to produce non-null values; the issue also links fix PR #58496.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100