Skip to content

Commit b659e4f

Browse files
committed
Fix crashes caused by zero or negative fontSize values
React Native crashes when fontSize is 0 or negative. Added safeFontSize utility to ensure minimum fontSize of 1 pixel. Fixed potentially dangerous calculations in IconBadge, FilledTextInput, FiatIcon, and ThemedIcons components.
1 parent 811b0bd commit b659e4f

18 files changed

+75
-50
lines changed

src/__tests__/components/__snapshots__/FilledTextInput.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ exports[`FilledTextInput should render with some props 1`] = `
146146
"value": {
147147
"color": "rgba(255, 255, 255, 0.5019607843137255)",
148148
"fontFamily": "anticon",
149-
"fontSize": 0,
149+
"fontSize": 1,
150150
"fontStyle": "normal",
151151
"fontWeight": "normal",
152152
},
@@ -158,7 +158,7 @@ exports[`FilledTextInput should render with some props 1`] = `
158158
{
159159
"color": "rgba(255, 255, 255, 0.5019607843137255)",
160160
"fontFamily": "anticon",
161-
"fontSize": 0,
161+
"fontSize": 1,
162162
"fontStyle": "normal",
163163
"fontWeight": "normal",
164164
},

src/__tests__/modals/__snapshots__/AddressModal.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ exports[`AddressModalComponent should render with loaded props 1`] = `
660660
"value": {
661661
"color": "rgba(255, 255, 255, 0.5019607843137255)",
662662
"fontFamily": "anticon",
663-
"fontSize": 0,
663+
"fontSize": 1,
664664
"fontStyle": "normal",
665665
"fontWeight": "normal",
666666
},
@@ -672,7 +672,7 @@ exports[`AddressModalComponent should render with loaded props 1`] = `
672672
{
673673
"color": "rgba(255, 255, 255, 0.5019607843137255)",
674674
"fontFamily": "anticon",
675-
"fontSize": 0,
675+
"fontSize": 1,
676676
"fontStyle": "normal",
677677
"fontWeight": "normal",
678678
},

src/__tests__/modals/__snapshots__/CategoryModal.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,7 @@ exports[`CategoryModal should render with an empty subcategory 1`] = `
25142514
"value": {
25152515
"color": "rgba(255, 255, 255, 0.5019607843137255)",
25162516
"fontFamily": "anticon",
2517-
"fontSize": 0,
2517+
"fontSize": 1,
25182518
"fontStyle": "normal",
25192519
"fontWeight": "normal",
25202520
},
@@ -2526,7 +2526,7 @@ exports[`CategoryModal should render with an empty subcategory 1`] = `
25262526
{
25272527
"color": "rgba(255, 255, 255, 0.5019607843137255)",
25282528
"fontFamily": "anticon",
2529-
"fontSize": 0,
2529+
"fontSize": 1,
25302530
"fontStyle": "normal",
25312531
"fontWeight": "normal",
25322532
},

src/__tests__/modals/__snapshots__/CountryListModal.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ exports[`CountryListModal should render with a country list 1`] = `
661661
"value": {
662662
"color": "rgba(255, 255, 255, 0.5019607843137255)",
663663
"fontFamily": "anticon",
664-
"fontSize": 0,
664+
"fontSize": 1,
665665
"fontStyle": "normal",
666666
"fontWeight": "normal",
667667
},
@@ -673,7 +673,7 @@ exports[`CountryListModal should render with a country list 1`] = `
673673
{
674674
"color": "rgba(255, 255, 255, 0.5019607843137255)",
675675
"fontFamily": "anticon",
676-
"fontSize": 0,
676+
"fontSize": 1,
677677
"fontStyle": "normal",
678678
"fontWeight": "normal",
679679
},

src/__tests__/modals/__snapshots__/LogsModal.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ exports[`LogsModal should render with a logs modal 1`] = `
839839
"value": {
840840
"color": "rgba(255, 255, 255, 0.5019607843137255)",
841841
"fontFamily": "anticon",
842-
"fontSize": 0,
842+
"fontSize": 1,
843843
"fontStyle": "normal",
844844
"fontWeight": "normal",
845845
},
@@ -851,7 +851,7 @@ exports[`LogsModal should render with a logs modal 1`] = `
851851
{
852852
"color": "rgba(255, 255, 255, 0.5019607843137255)",
853853
"fontFamily": "anticon",
854-
"fontSize": 0,
854+
"fontSize": 1,
855855
"fontStyle": "normal",
856856
"fontWeight": "normal",
857857
},

src/__tests__/modals/__snapshots__/PasswordReminderModal.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ Please enter your password below. A successful verification will prevent this wa
767767
"value": {
768768
"color": "rgba(255, 255, 255, 0.5019607843137255)",
769769
"fontFamily": "anticon",
770-
"fontSize": 0,
770+
"fontSize": 1,
771771
"fontStyle": "normal",
772772
"fontWeight": "normal",
773773
},
@@ -779,7 +779,7 @@ Please enter your password below. A successful verification will prevent this wa
779779
{
780780
"color": "rgba(255, 255, 255, 0.5019607843137255)",
781781
"fontFamily": "anticon",
782-
"fontSize": 0,
782+
"fontSize": 1,
783783
"fontStyle": "normal",
784784
"fontWeight": "normal",
785785
},

src/__tests__/modals/__snapshots__/TextInputModal.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ exports[`TextInputModal should render with a blank input field 1`] = `
584584
"value": {
585585
"color": "rgba(255, 255, 255, 0.5019607843137255)",
586586
"fontFamily": "anticon",
587-
"fontSize": 0,
587+
"fontSize": 1,
588588
"fontStyle": "normal",
589589
"fontWeight": "normal",
590590
},
@@ -596,7 +596,7 @@ exports[`TextInputModal should render with a blank input field 1`] = `
596596
{
597597
"color": "rgba(255, 255, 255, 0.5019607843137255)",
598598
"fontFamily": "anticon",
599-
"fontSize": 0,
599+
"fontSize": 1,
600600
"fontStyle": "normal",
601601
"fontWeight": "normal",
602602
},

src/__tests__/modals/__snapshots__/WalletListModal.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ exports[`WalletListModal should render with loading props 1`] = `
482482
"value": {
483483
"color": "rgba(255, 255, 255, 0.5019607843137255)",
484484
"fontFamily": "Material Icons",
485-
"fontSize": 0,
485+
"fontSize": 1,
486486
"fontStyle": "normal",
487487
"fontWeight": "normal",
488488
},
@@ -494,7 +494,7 @@ exports[`WalletListModal should render with loading props 1`] = `
494494
{
495495
"color": "rgba(255, 255, 255, 0.5019607843137255)",
496496
"fontFamily": "Material Icons",
497-
"fontSize": 0,
497+
"fontSize": 1,
498498
"fontStyle": "normal",
499499
"fontWeight": "normal",
500500
},
@@ -665,7 +665,7 @@ exports[`WalletListModal should render with loading props 1`] = `
665665
"value": {
666666
"color": "rgba(255, 255, 255, 0.5019607843137255)",
667667
"fontFamily": "anticon",
668-
"fontSize": 0,
668+
"fontSize": 1,
669669
"fontStyle": "normal",
670670
"fontWeight": "normal",
671671
},
@@ -677,7 +677,7 @@ exports[`WalletListModal should render with loading props 1`] = `
677677
{
678678
"color": "rgba(255, 255, 255, 0.5019607843137255)",
679679
"fontFamily": "anticon",
680-
"fontSize": 0,
680+
"fontSize": 1,
681681
"fontStyle": "normal",
682682
"fontWeight": "normal",
683683
},

src/__tests__/scenes/__snapshots__/CreateWalletAccountSetupScene.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ exports[`CreateWalletAccountSelect renders 1`] = `
845845
"value": {
846846
"color": "rgba(255, 255, 255, 0.5019607843137255)",
847847
"fontFamily": "anticon",
848-
"fontSize": 0,
848+
"fontSize": 1,
849849
"fontStyle": "normal",
850850
"fontWeight": "normal",
851851
},
@@ -857,7 +857,7 @@ exports[`CreateWalletAccountSelect renders 1`] = `
857857
{
858858
"color": "rgba(255, 255, 255, 0.5019607843137255)",
859859
"fontFamily": "anticon",
860-
"fontSize": 0,
860+
"fontSize": 1,
861861
"fontStyle": "normal",
862862
"fontWeight": "normal",
863863
},

src/__tests__/scenes/__snapshots__/CreateWalletImportScene.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ exports[`CreateWalletImportScene should render with loading props 1`] = `
813813
"value": {
814814
"color": "rgba(255, 255, 255, 0.5019607843137255)",
815815
"fontFamily": "anticon",
816-
"fontSize": 0,
816+
"fontSize": 1,
817817
"fontStyle": "normal",
818818
"fontWeight": "normal",
819819
},
@@ -825,7 +825,7 @@ exports[`CreateWalletImportScene should render with loading props 1`] = `
825825
{
826826
"color": "rgba(255, 255, 255, 0.5019607843137255)",
827827
"fontFamily": "anticon",
828-
"fontSize": 0,
828+
"fontSize": 1,
829829
"fontStyle": "normal",
830830
"fontWeight": "normal",
831831
},

0 commit comments

Comments
 (0)