Limit text length and number of level labels

This commit is contained in:
Slendy 2022-09-18 15:27:54 -05:00
parent 40d7562660
commit 2a44e85a30
No known key found for this signature in database
GPG key ID: 7288D68361B91428
3 changed files with 5 additions and 3 deletions

View file

@ -29,10 +29,10 @@ public class SlotSettingsPage : BaseLayout
if (avatarHash != null) this.Slot.IconHash = avatarHash;
name = SanitizationHelper.SanitizeString(name);
if (this.Slot.Name != name) this.Slot.Name = name;
if (this.Slot.Name != name && name.Length <= 64) this.Slot.Name = name;
description = SanitizationHelper.SanitizeString(description);
if (this.Slot.Description != description) this.Slot.Description = description;
if (this.Slot.Description != description && description.Length <= 512) this.Slot.Description = description;
labels = LabelHelper.RemoveInvalidLabels(SanitizationHelper.SanitizeString(labels));
if (this.Slot.AuthorLabels != labels) this.Slot.AuthorLabels = labels;

View file

@ -37,7 +37,7 @@ public class UserSettingsPage : BaseLayout
biography = SanitizationHelper.SanitizeString(biography);
if (this.ProfileUser.Biography != biography) this.ProfileUser.Biography = biography;
if (this.ProfileUser.Biography != biography && biography.Length <= 512) this.ProfileUser.Biography = biography;
if (ServerConfiguration.Instance.Mail.MailEnabled && IsValidEmail(email) && (this.User == this.ProfileUser || this.User.IsAdmin))
{

View file

@ -110,6 +110,8 @@ public static class LabelHelper
public static string RemoveInvalidLabels(string authorLabels)
{
List<string> labels = new(authorLabels.Split(","));
if (labels.Count > 5) labels = labels.GetRange(0, 5);
for (int i = labels.Count - 1; i >= 0; i--)
{
if (!IsValidLabel(labels[i])) labels.Remove(labels[i]);