From 4ebaec79708db18995346a3e349d75d7ea050535 Mon Sep 17 00:00:00 2001 From: Brian Yencho Date: Mon, 23 Oct 2023 13:44:55 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20crash=20when=20parsing=20JWT=20and=20'nam?= =?UTF-8?q?e'=20property=20is=20not=20present=20in=20the=20=E2=80=A6=20(#1?= =?UTF-8?q?46)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: David Perez --- .../bitwarden/data/auth/repository/util/JwtTokenUtils.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/util/JwtTokenUtils.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/util/JwtTokenUtils.kt index 5b57472b3..595cdd303 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/util/JwtTokenUtils.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/util/JwtTokenUtils.kt @@ -2,12 +2,19 @@ package com.x8bit.bitwarden.data.auth.repository.util import com.x8bit.bitwarden.data.auth.repository.model.JwtTokenDataJson import com.x8bit.bitwarden.data.platform.datasource.network.util.base64UrlDecodeOrNull +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json /** * Internal, generally basic [Json] instance for JWT parsing purposes. */ -private val json by lazy { Json { ignoreUnknownKeys = true } } +@OptIn(ExperimentalSerializationApi::class) +private val json: Json by lazy { + Json { + ignoreUnknownKeys = true + explicitNulls = false + } +} /** * Parses a [JwtTokenDataJson] from the given [jwtToken], or `null` if this parsing is not possible.