Skip to content

Commit 19bc65a

Browse files
committed
fix(expo): reject 3-digit hex in theme validation and fix Android 8-digit hex ordering
- Remove 3-digit hex (#RGB) from the prebuild validation regex. Both native parsers only handle 6- or 8-digit hex, so 3-digit values would pass validation but be silently ignored at runtime. - Convert RRGGBBAA to AARRGGBB on Android before passing to parseColor. iOS already parses 8-digit hex as RRGGBBAA, so without this conversion the same color token could render differently on each platform.
1 parent b5af733 commit 19bc65a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

packages/expo/android/src/main/java/expo/modules/clerk/ClerkExpoModule.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,12 @@ class ClerkExpoModule(reactContext: ReactApplicationContext) :
438438
return try {
439439
when (cleaned.length) {
440440
6 -> Color(android.graphics.Color.parseColor("#FF$cleaned"))
441-
8 -> Color(android.graphics.Color.parseColor("#$cleaned"))
441+
// Theme JSON uses RRGGBBAA; Android parseColor expects AARRGGBB
442+
8 -> {
443+
val rrggbb = cleaned.substring(0, 6)
444+
val aa = cleaned.substring(6, 8)
445+
Color(android.graphics.Color.parseColor("#$aa$rrggbb"))
446+
}
442447
else -> null
443448
}
444449
} catch (e: Exception) {

packages/expo/app.plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ const VALID_COLOR_KEYS = [
618618
'shadow',
619619
];
620620

621-
const HEX_COLOR_REGEX = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
621+
const HEX_COLOR_REGEX = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
622622

623623
function validateThemeJson(theme) {
624624
const validateColors = (colors, label) => {

0 commit comments

Comments
 (0)