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, and rgba(1,2,3,0.5)extra
- Observe non-null
processColor values and painted swatches (bug). Spaced hex #fff correctly 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
Fix PR: #58496
Description
@react-native/normalize-colorsfully anchors hex matchers (^…$) but notrgb/rgba/hsl/hsla/hwb. Substring matches are therefore accepted:Steps to reproduce
xxrgb(1, 2, 3)yy,rgb(1, 2, 3)yy, andrgba(1,2,3,0.5)extraprocessColorvalues and painted swatches (bug). Spaced hex#fffcorrectly stays null.React Native Version
main/ latest (package@react-native/normalize-colors, used byprocessColor)Affected Platforms
@react-native/normalize-colorsOutput of
npx @react-native-community/cli infoN/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
Fix PR: #58496