From bfeff9f9b0821e7b35fcc7322f235d9b43c62c73 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Wed, 21 Dec 2022 12:00:16 +0100 Subject: take extra care for wrongly formatted strings when using spannables in TetheringDialog --- .../se/leap/bitmaskclient/base/fragments/TetheringDialog.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java index 675f1a61..e747d5b4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java @@ -209,10 +209,18 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer int endIndex = 0; if (matcher.matches()) { startIndex = matcher.start(2); - endIndex = startIndex + matcher.group(3).length(); + try { + endIndex = startIndex + matcher.group(3).length(); + } catch (NullPointerException npe) { + endIndex = -1; + } } systemSettingsMessage = systemSettingsMessage.replace("", "").replace("", ""); String wholeMessage = systemSettingsMessage + "\n\n" + tetheringMessage; + if (startIndex == -1 || endIndex == -1) { + Log.e(TAG, "Tethering string has wrong formatting!"); + return wholeMessage; + } Spannable spannable = new SpannableString(wholeMessage); spannable.setSpan(new ClickableSpan() { @Override -- cgit v1.2.3