From fe0af7e720cf17fdbf49842c94ba2d05f6055daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 20 May 2024 11:36:39 +0200 Subject: [PATCH] Fix unnecessary padding of empty strings for discord RPC purposes Closes https://github.com/ppy/osu/issues/28248. Destroy all software. --- osu.Desktop/DiscordRichPresence.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 3e0a9099cb..780d367900 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -273,7 +273,11 @@ private void onJoin(object sender, JoinMessage args) => Scheduler.AddOnce(() => private static string clampLength(string str) { - // For whatever reason, discord decides that strings shorter than 2 characters cannot possibly be valid input, because... reasons? + // Empty strings are fine to discord even though single-character strings are not. Make it make sense. + if (string.IsNullOrEmpty(str)) + return str; + + // As above, discord decides that *non-empty* strings shorter than 2 characters cannot possibly be valid input, because... reasons? // And yes, that is two *characters*, or *codepoints*, not *bytes* as further down below (as determined by empirical testing). // That seems very questionable, and isn't even documented anywhere. So to *make it* accept such valid input, // just tack on enough of U+200B ZERO WIDTH SPACEs at the end.