normalize-color accepts functional colors with surrounding junk
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript, react-native
- Domain
- mobile
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.
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
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.3k
- PR merge metrics
- No merged PRs in 30d
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.
More from react/react-native
-
Needs: Author Feedback Needs: Repro
Difficulty 1/5 Under an hour Newbie friendliness 92/100
react/react-native#58621 · 1 comment ·
-
Needs: Author Feedback Needs: Repro
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
react/react-native#58610 · 1 comment ·
-
Needs: Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
react/react-native#58565 · 1 comment · 2 reactions ·
-
Needs: Author Feedback Needs: Repro
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
react/react-native#58555 · 5 comments · 2 reactions ·
-
Needs: Attention Needs: Repro
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
react/react-native#58526 · 2 comments ·
All issues in react/react-native
Similar issues
-
AuTest Bug Tests
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/trafficserver#13714 ·
-
bug build
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
facebookincubator/velox#19143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tenstorrent/tt-metal#57393 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·