From 91a51f01f2bf1a6b4d9e43a8f17afd980de5bdfb Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 23 Jul 2025 15:18:23 +0700 Subject: [PATCH 1/5] fix: onTextContextMenuItem crash --- .../react-native+0.79.2+011+Add-onPaste-to-TextInput.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch index 80f24ebba436..de94bd1b6f44 100644 --- a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch @@ -513,7 +513,7 @@ index 42f2383..9a98163 100644 + } + } + -+ if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { ++ if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN) && item.getText() != null) { + type = ClipDescription.MIMETYPE_TEXT_PLAIN; + data = item.getText().toString(); + if (mPasteWatcher != null) { From 4df6c2dd86872a18f75008b476ade8a3ac8fc893 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 28 Jul 2025 00:16:28 +0700 Subject: [PATCH 2/5] fix: avoid calling getText twice --- ...t-native+0.79.2+011+Add-onPaste-to-TextInput.patch | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch index de94bd1b6f44..5fcf8db6cdf1 100644 --- a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch @@ -513,11 +513,14 @@ index 42f2383..9a98163 100644 + } + } + -+ if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN) && item.getText() != null) { ++ if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { + type = ClipDescription.MIMETYPE_TEXT_PLAIN; -+ data = item.getText().toString(); -+ if (mPasteWatcher != null) { -+ mPasteWatcher.onPaste(type, data); ++ CharSequence text = item.getText(); ++ if (text != null) { ++ data = text.toString(); ++ if (mPasteWatcher != null) { ++ mPasteWatcher.onPaste(type, data); ++ } + } + // Don't return - let the system proceed with default text pasting behavior + } From e94e0451d0add786c220289260e081e24c3a9211 Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 29 Jul 2025 22:18:36 +0700 Subject: [PATCH 3/5] revert previous changes --- ...eact-native+0.79.2+011+Add-onPaste-to-TextInput.patch | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch index 5fcf8db6cdf1..80f24ebba436 100644 --- a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch @@ -515,12 +515,9 @@ index 42f2383..9a98163 100644 + + if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { + type = ClipDescription.MIMETYPE_TEXT_PLAIN; -+ CharSequence text = item.getText(); -+ if (text != null) { -+ data = text.toString(); -+ if (mPasteWatcher != null) { -+ mPasteWatcher.onPaste(type, data); -+ } ++ data = item.getText().toString(); ++ if (mPasteWatcher != null) { ++ mPasteWatcher.onPaste(type, data); + } + // Don't return - let the system proceed with default text pasting behavior + } From ba2c76ec40f222f365bc9603ede9c61d1778b3b4 Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 29 Jul 2025 22:29:00 +0700 Subject: [PATCH 4/5] create new patch --- patches/react-native/details.md | 7 +++++ ...+fix-clipboard-text-data-can-be-null.patch | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch diff --git a/patches/react-native/details.md b/patches/react-native/details.md index 608cd99c1809..a0a6f2f424d6 100644 --- a/patches/react-native/details.md +++ b/patches/react-native/details.md @@ -190,3 +190,10 @@ - Upstream PR/issue: https://github.com/facebook/react-native/pull/50782 - E/App issue: https://github.com/Expensify/App/issues/64900 - PR introducing patch: [#65804](https://github.com/Expensify/App/pull/65804) + +### [react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch](react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch) + +- Reason: This patch fixes a crash that occurred when the clipboard text data can be null. +- Upstream PR/issue: 🛑 +- E/App issue: [#66925](https://github.com/Expensify/App/issues/66925) +- PR introducing patch: [#66749](https://github.com/Expensify/App/pull/66749) \ No newline at end of file diff --git a/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch b/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch new file mode 100644 index 000000000000..2969320bfe3e --- /dev/null +++ b/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch @@ -0,0 +1,27 @@ +diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +index 5a05e82..095313e 100644 +--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java ++++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +@@ -370,9 +370,12 @@ public class ReactEditText extends AppCompatEditText { + + if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { + type = ClipDescription.MIMETYPE_TEXT_PLAIN; +- data = item.getText().toString(); +- if (mPasteWatcher != null) { +- mPasteWatcher.onPaste(type, data); ++ CharSequence text = item.getText(); ++ if (text != null) { ++ data = text.toString(); ++ if (mPasteWatcher != null) { ++ mPasteWatcher.onPaste(type, data); ++ } + } + // Don't return - let the system proceed with default text pasting behavior + } +diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env +new file mode 100644 +index 0000000..361f5fb +--- /dev/null ++++ b/node_modules/react-native/scripts/.packager.env +@@ -0,0 +1 @@ ++export RCT_METRO_PORT=8081 From 6657729fe7edb63f3026d1a9ac5449c3b3cc8afc Mon Sep 17 00:00:00 2001 From: daledah Date: Thu, 31 Jul 2025 15:47:45 +0700 Subject: [PATCH 5/5] fix: remove redundant patch --- ...ve+0.79.2+027+fix-clipboard-text-data-can-be-null.patch | 7 ------- 1 file changed, 7 deletions(-) diff --git a/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch b/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch index 2969320bfe3e..70a813a72065 100644 --- a/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch +++ b/patches/react-native/react-native+0.79.2+027+fix-clipboard-text-data-can-be-null.patch @@ -18,10 +18,3 @@ index 5a05e82..095313e 100644 } // Don't return - let the system proceed with default text pasting behavior } -diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env -new file mode 100644 -index 0000000..361f5fb ---- /dev/null -+++ b/node_modules/react-native/scripts/.packager.env -@@ -0,0 +1 @@ -+export RCT_METRO_PORT=8081