mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 10:28:28 +03:00
EC-323 sanitize data on get first letters for avatar image creation (#1990)
This commit is contained in:
parent
70cf7431f7
commit
8f3a4b98a5
1 changed files with 10 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
@ -131,21 +132,23 @@ namespace Bit.App.Controls
|
||||||
|
|
||||||
private string GetFirstLetters(string data, int charCount)
|
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)
|
if (parts.Length > 1 && charCount <= 2)
|
||||||
{
|
{
|
||||||
var text = "";
|
var text = string.Empty;
|
||||||
for (int i = 0; i < charCount; i++)
|
for (var i = 0; i < charCount; i++)
|
||||||
{
|
{
|
||||||
text += parts[i].Substring(0, 1);
|
text += parts[i][0];
|
||||||
}
|
}
|
||||||
return text;
|
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)
|
private Color StringToColor(string str)
|
||||||
|
|
Loading…
Reference in a new issue