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

Commit 66f6999c authored by Andrew Chen's avatar Andrew Chen Committed by Jesse Vincent
Browse files

Fix for NPE introduced in r3258.

parent 40bdf999
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -47,19 +47,30 @@ public class MessageReference implements Serializable
        {
            // Split the identity, stripping away the first two characters representing the version and delimiter.
            StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false);
            if (tokens.countTokens() == 4)
            if (tokens.countTokens() >= 3)
            {
                accountUuid = Utility.base64Decode(tokens.nextToken());
                folderName = Utility.base64Decode(tokens.nextToken());
                uid = Utility.base64Decode(tokens.nextToken());
                flag = Flag.valueOf(tokens.nextToken());

                if (tokens.hasMoreTokens())
                {
                    final String flagString = tokens.nextToken();
                    try
                    {
                        flag = Flag.valueOf(flagString);
                    } catch (IllegalArgumentException ie)
                    {
                        throw new MessagingException("Could not thaw message flag '" + flagString + "'", ie);
                    }
                }

                if (K9.DEBUG)
                    Log.d(K9.LOG_TAG, "Thawed " + toString());
            }
            else
            {
                throw new MessagingException("Invalid token in " + IDENTITY_SEPARATOR + " identity.");
                throw new MessagingException("Invalid MessageReference in " + identity + " identity.");
            }
        }
    }
@@ -80,8 +91,11 @@ public class MessageReference implements Serializable
        refString.append(Utility.base64Encode(folderName));
        refString.append(IDENTITY_SEPARATOR);
        refString.append(Utility.base64Encode(uid));
        if (flag != null)
        {
            refString.append(IDENTITY_SEPARATOR);
            refString.append(flag.name());
        }

        return refString.toString();
    }