Trim user input so stuff doesn't break
This commit is contained in:
@@ -16,6 +16,9 @@ internal static class StringExtensions
|
||||
#if !INCOGNIFY_STRINGS
|
||||
return str;
|
||||
#endif
|
||||
|
||||
str = str.Trim();
|
||||
|
||||
if (str.Contains(" "))
|
||||
{
|
||||
var split = str.Split(' ');
|
||||
|
||||
@@ -145,8 +145,8 @@ public sealed class Profile : ISavable
|
||||
{
|
||||
CreationDate = creationDate,
|
||||
UniqueId = obj["UniqueId"]?.ToObject<Guid>() ?? throw new ArgumentNullException("UniqueId"),
|
||||
Name = new LowerString(obj["Name"]?.ToObject<string>() ?? throw new ArgumentNullException("Name")),
|
||||
CharacterName = new LowerString(obj["CharacterName"]?.ToObject<string>() ?? throw new ArgumentNullException("CharacterName")),
|
||||
Name = new LowerString(obj["Name"]?.ToObject<string>()?.Trim() ?? throw new ArgumentNullException("Name")),
|
||||
CharacterName = new LowerString(obj["CharacterName"]?.ToObject<string>()?.Trim() ?? throw new ArgumentNullException("CharacterName")),
|
||||
LimitLookupToOwnedObjects = obj["LimitLookupToOwnedObjects"]?.ToObject<bool>() ?? throw new ArgumentNullException("LimitLookupToOwnedObjects"),
|
||||
Enabled = obj["Enabled"]?.ToObject<bool>() ?? throw new ArgumentNullException("Enabled"),
|
||||
ModifiedDate = obj["ModifiedDate"]?.ToObject<DateTimeOffset>() ?? creationDate,
|
||||
|
||||
@@ -199,6 +199,8 @@ public class ProfileManager : IDisposable
|
||||
/// </summary>
|
||||
public void Rename(Profile profile, string newName)
|
||||
{
|
||||
newName = newName.Trim();
|
||||
|
||||
var oldName = profile.Name.Text;
|
||||
if (oldName == newName)
|
||||
return;
|
||||
@@ -216,6 +218,8 @@ public class ProfileManager : IDisposable
|
||||
/// </summary>
|
||||
public void ChangeCharacterName(Profile profile, string newName)
|
||||
{
|
||||
newName = newName.Trim();
|
||||
|
||||
var oldName = profile.CharacterName.Text;
|
||||
if (oldName == newName)
|
||||
return;
|
||||
|
||||
@@ -93,7 +93,7 @@ public sealed class Template : ISavable
|
||||
{
|
||||
CreationDate = creationDate,
|
||||
UniqueId = obj["UniqueId"]?.ToObject<Guid>() ?? throw new ArgumentNullException("UniqueId"),
|
||||
Name = new LowerString(obj["Name"]?.ToObject<string>() ?? throw new ArgumentNullException("Name")),
|
||||
Name = new LowerString(obj["Name"]?.ToObject<string>()?.Trim() ?? throw new ArgumentNullException("Name")),
|
||||
ModifiedDate = obj["ModifiedDate"]?.ToObject<DateTimeOffset>() ?? creationDate,
|
||||
Bones = obj["Bones"]?.ToObject<Dictionary<string, BoneTransform>>() ?? throw new ArgumentNullException("Bones"),
|
||||
IsWriteProtected = obj["IsWriteProtected"]?.ToObject<bool>() ?? false
|
||||
|
||||
@@ -141,6 +141,8 @@ public class TemplateManager
|
||||
/// </summary>
|
||||
public void Rename(Template template, string newName)
|
||||
{
|
||||
newName = newName.Trim();
|
||||
|
||||
var oldName = template.Name.Text;
|
||||
if (oldName == newName)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user