Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df337f30 authored by Nils Holmström's avatar Nils Holmström Committed by Takeshi Aimi
Browse files

Fix NPE when pasting non-text from Clipboard

When copying a link from a bookmark and then pasting it into
a textfield a NullPointerException will occur.
A ClipData.Item is not guaranteed to always contain a text string
and therefore getText() can be set to null.

Using method coerceToText() instead of getText() makes sure that
a text string is always returned.

Change-Id: I81343c0371835a3a7a52045dcd1760e69e59a967
parent c9e0cd2a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5416,7 +5416,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        ClipData clipData = cm.getPrimaryClip();
        if (clipData != null) {
            ClipData.Item clipItem = clipData.getItemAt(0);
            CharSequence pasteText = clipItem.getText();
            CharSequence pasteText = clipItem.coerceToText(mContext);
            if (mInputConnection != null) {
                mInputConnection.replaceSelection(pasteText);
            }