1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-28 12:35:40 +01:00

Fixes a mojibake bug in web authenticators in some multibyte locales

Fixes #3345

Make the implementation of the character convertion consistent with
their consumers in the web app.
This commit is contained in:
Yuki Yugui Sonoda 2024-07-07 15:44:47 +09:00
parent 8a43bb4655
commit 4e2cec88e4

View File

@ -515,14 +515,8 @@ namespace Bit.App.Utilities
public static string EncodeDataParameter(object obj)
{
string EncodeMultibyte(Match match)
{
return Convert.ToChar(Convert.ToUInt32($"0x{match.Groups[1].Value}", 16)).ToString();
}
var escaped = Uri.EscapeDataString(JsonConvert.SerializeObject(obj));
var multiByteEscaped = Regex.Replace(escaped, "%([0-9A-F]{2})", EncodeMultibyte);
return WebUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(multiByteEscaped)));
var json = JsonConvert.SerializeObject(obj);
return WebUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(json)));
}
public static async Task LogOutAsync(string userId, bool userInitiated = false)