diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt index 447697770..4b60f9b7b 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt @@ -97,14 +97,10 @@ object Utils { * base64 decode */ fun decode(text: String?): String { - tryDecodeBase64(text)?.let { return it } - if (text?.endsWith('=')==true) { - // try again for some loosely formatted base64 - tryDecodeBase64(text.trimEnd('='))?.let { return it } - } - return "" + return tryDecodeBase64(text) ?: text?.trimEnd('=')?.let { tryDecodeBase64(it) } ?: "" } + fun tryDecodeBase64(text: String?): String? { try { return Base64.decode(text, Base64.NO_WRAP).toString(Charsets.UTF_8)