From 011aa0cd9088ea069982045d33ba82dedf2c803d Mon Sep 17 00:00:00 2001 From: ruri Date: Wed, 29 May 2019 11:49:46 +0200 Subject: [PATCH] Fixed problem in Base64Decode with some badly formatted tokens. --- RuriLib/Blocks/BlockFunction.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RuriLib/Blocks/BlockFunction.cs b/RuriLib/Blocks/BlockFunction.cs index 1e867a8..77f7cf4 100644 --- a/RuriLib/Blocks/BlockFunction.cs +++ b/RuriLib/Blocks/BlockFunction.cs @@ -727,7 +727,10 @@ namespace RuriLib /// The decoded string public static string Base64Decode(string base64EncodedData) { - var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); + var toDecode = base64EncodedData.Replace(".", ""); + var remainder = toDecode.Length % 4; + if (remainder != 0) toDecode = toDecode.PadRight(toDecode.Length + remainder, '='); + var base64EncodedBytes = System.Convert.FromBase64String(toDecode); return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); } #endregion