deltachat / deltachat-android

Email-based instant messaging for Android.
GNU General Public License v3.0
1.1k stars 144 forks source link

index out of bounds in mailto parser #3157

Closed r10s closed 2 months ago

r10s commented 2 months ago

from gplay console:

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3800)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3937)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:101)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:137)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2423)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at android.app.ActivityThread.main (ActivityThread.java:8115)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:703)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:911)
Caused by java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
  at org.thoughtcrime.securesms.util.MailtoUtil.getMailtoQueryMap (MailtoUtil.java:56)
  at org.thoughtcrime.securesms.util.MailtoUtil.getText (MailtoUtil.java:35)
  at org.thoughtcrime.securesms.ShareActivity.initializeMedia (ShareActivity.java:125)
  at org.thoughtcrime.securesms.ShareActivity.onCreate (ShareActivity.java:79)
  at org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity.onCreate (PassphraseRequiredActionBarActivity.java:42)
  at android.app.Activity.performCreate (Activity.java:8353)
  at android.app.Activity.performCreate (Activity.java:8332)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1388)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3780)

i assume this happens when trying to open links as mailto:?subject (so without a parameter, so that index#1 is empty)

we are already using try/error in the code snippet, however we're for whatever reasons picky about the exception type :) EDIT: one code path does a separate catch, however, another does not.

fix would probably just be to catch all exceptions in MailtoUtil.getMailtoQueryMap()