diff options
author | cyBerta <cyberta@riseup.net> | 2022-12-21 12:00:16 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2022-12-21 12:00:16 +0100 |
commit | bfeff9f9b0821e7b35fcc7322f235d9b43c62c73 (patch) | |
tree | 513d96d9496666bd5499695d7091542e1e0bd8dd | |
parent | 51e2e18f6c8d4ac2fa048e8a8195d186d342ec62 (diff) |
take extra care for wrongly formatted strings when using spannables in TetheringDialog
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java | 10 |
1 files changed, 9 insertions, 1 deletions
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("<b>", "").replace("</b>", ""); 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 |