From 5cc3f9ee304ff4d361cfdd4e2f13d9b2219df5d5 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 24 Oct 2021 19:28:25 +1100 Subject: [PATCH] Truncate long name / job titles for IDs (#5009) --- .../Access/UI/IdCardConsoleBoundUserInterface.cs | 7 +++++++ Content.Server/Access/Systems/IdCardSystem.cs | 8 ++++++++ Content.Shared/Access/SharedIdCardConsoleComponent.cs | 3 +++ 3 files changed, 18 insertions(+) diff --git a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs index d8703ab376..d28789fd69 100644 --- a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs +++ b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Content.Shared.Access; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -40,6 +41,12 @@ namespace Content.Client.Access.UI public void SubmitData(string newFullName, string newJobTitle, List newAccessList) { + if (newFullName.Length > MaxFullNameLength) + newFullName = newFullName[..MaxFullNameLength]; + + if (newJobTitle.Length > MaxJobTitleLength) + newJobTitle = newJobTitle[..MaxJobTitleLength]; + SendMessage(new WriteToTargetIdMessage( newFullName, newJobTitle, diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index 02b113a6a4..034ede7a88 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Access.Components; +using Content.Shared.Access; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -23,6 +24,10 @@ namespace Content.Server.Access.Systems if (!Resolve(uid, ref id)) return false; + // TODO: Whenever we get admin logging these should be logged + if (jobTitle.Length > SharedIdCardConsoleComponent.MaxJobTitleLength) + jobTitle = jobTitle[..SharedIdCardConsoleComponent.MaxJobTitleLength]; + id.JobTitle = jobTitle; UpdateEntityName(uid, id); return true; @@ -33,6 +38,9 @@ namespace Content.Server.Access.Systems if (!Resolve(uid, ref id)) return false; + if (fullName.Length > SharedIdCardConsoleComponent.MaxFullNameLength) + fullName = fullName[..SharedIdCardConsoleComponent.MaxFullNameLength]; + id.FullName = fullName; UpdateEntityName(uid, id); return true; diff --git a/Content.Shared/Access/SharedIdCardConsoleComponent.cs b/Content.Shared/Access/SharedIdCardConsoleComponent.cs index 3983febb2b..61f7ffdf4b 100644 --- a/Content.Shared/Access/SharedIdCardConsoleComponent.cs +++ b/Content.Shared/Access/SharedIdCardConsoleComponent.cs @@ -9,6 +9,9 @@ namespace Content.Shared.Access { public override string Name => "IdCardConsole"; + public const int MaxFullNameLength = 256; + public const int MaxJobTitleLength = 256; + public enum UiButton { PrivilegedId,