From 7bdc3020b02c78856bae7cde44f5e68234223dcd Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 3 Feb 2020 15:05:05 +0100 Subject: [PATCH] Handle malformed proxy tag importing correctly --- PluralKit.Core/DataFiles.cs | 3 ++- PluralKit.Core/Models.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PluralKit.Core/DataFiles.cs b/PluralKit.Core/DataFiles.cs index 23ec3aaf..0e3b21f3 100644 --- a/PluralKit.Core/DataFiles.cs +++ b/PluralKit.Core/DataFiles.cs @@ -162,7 +162,8 @@ namespace PluralKit.Bot } else { - member.ProxyTags = dataMember.ProxyTags ?? new ProxyTag[] { }; + // Ignore proxy tags where both prefix and suffix are set to null (would be invalid anyway) + member.ProxyTags = (dataMember.ProxyTags ?? new ProxyTag[] { }).Where(tag => !tag.IsEmpty).ToList(); } member.KeepProxy = dataMember.KeepProxy; diff --git a/PluralKit.Core/Models.cs b/PluralKit.Core/Models.cs index f044a3a8..ecb71ba3 100644 --- a/PluralKit.Core/Models.cs +++ b/PluralKit.Core/Models.cs @@ -51,6 +51,8 @@ namespace PluralKit [JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}"; + public bool IsEmpty => Prefix == null && Suffix == null; + public bool Equals(ProxyTag other) => Prefix == other.Prefix && Suffix == other.Suffix; public override bool Equals(object obj) => obj is ProxyTag other && Equals(other);