Prevent null values from being censored

This commit is contained in:
Slendy 2023-04-03 01:02:41 -05:00
parent 89556d5dfa
commit d6788f0965
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 24 additions and 9 deletions

View file

@ -29,14 +29,26 @@ public class SlotSettingsPage : BaseLayout
if (avatarHash != null) this.Slot.IconHash = avatarHash; if (avatarHash != null) this.Slot.IconHash = avatarHash;
name = CensorHelper.FilterMessage(name); if (name != null)
if (this.Slot.Name != name && name.Length <= 64) this.Slot.Name = name; {
name = CensorHelper.FilterMessage(name);
if (this.Slot.Name != name && name.Length <= 64)
this.Slot.Name = name;
}
description = CensorHelper.FilterMessage(description); if (description != null)
if (this.Slot.Description != description && description.Length <= 512) this.Slot.Description = description; {
description = CensorHelper.FilterMessage(description);
if (this.Slot.Description != description && description?.Length <= 512)
this.Slot.Description = description;
}
labels = LabelHelper.RemoveInvalidLabels(labels); if (labels != null)
if (this.Slot.AuthorLabels != labels) this.Slot.AuthorLabels = labels; {
labels = LabelHelper.RemoveInvalidLabels(labels);
if (this.Slot.AuthorLabels != labels)
this.Slot.AuthorLabels = labels;
}
// ReSharper disable once InvertIf // ReSharper disable once InvertIf
if (this.Database.ChangeTracker.HasChanges()) if (this.Database.ChangeTracker.HasChanges())

View file

@ -33,9 +33,12 @@ public class UserSettingsPage : BaseLayout
if (avatarHash != null) this.ProfileUser.IconHash = avatarHash; if (avatarHash != null) this.ProfileUser.IconHash = avatarHash;
biography = CensorHelper.FilterMessage(biography); if (biography != null)
{
if (this.ProfileUser.Biography != biography && biography.Length <= 512) this.ProfileUser.Biography = biography; biography = CensorHelper.FilterMessage(biography);
if (this.ProfileUser.Biography != biography && biography.Length <= 512)
this.ProfileUser.Biography = biography;
}
if (ServerConfiguration.Instance.Mail.MailEnabled && if (ServerConfiguration.Instance.Mail.MailEnabled &&
SanitizationHelper.IsValidEmail(email) && SanitizationHelper.IsValidEmail(email) &&