1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-28 17:18:23 +01:00

EC-323 sanitize data on get first letters for avatar image creation (#1990)

This commit is contained in:
Federico Maccaroni 2022-07-14 17:33:30 -03:00 committed by GitHub
parent 70cf7431f7
commit 8f3a4b98a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using SkiaSharp;
@ -131,21 +132,23 @@ namespace Bit.App.Controls
private string GetFirstLetters(string data, int charCount)
{
var parts = data.Split();
var sanitizedData = data.Trim();
var parts = sanitizedData.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length > 1 && charCount <= 2)
{
var text = "";
for (int i = 0; i < charCount; i++)
var text = string.Empty;
for (var i = 0; i < charCount; i++)
{
text += parts[i].Substring(0, 1);
text += parts[i][0];
}
return text;
}
if (data.Length > 2)
if (sanitizedData.Length > 2)
{
return data.Substring(0, 2);
return sanitizedData.Substring(0, 2);
}
return data;
return sanitizedData;
}
private Color StringToColor(string str)