1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 14:37:30 +08:00

Fix discord RPC complaining yet again if given a single space character as activity state / details

Closes https://github.com/ppy/osu/issues/30178.

Really, discord?
This commit is contained in:
Bartłomiej Dach 2024-10-10 13:54:32 +02:00
parent cab97a96ab
commit a7fcfd5f0d
No known key found for this signature in database

View File

@ -279,10 +279,12 @@ namespace osu.Desktop
// As above, discord decides that *non-empty* strings shorter than 2 characters cannot possibly be valid input, because... reasons? // 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). // 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, // Also, spaces don't count. Because reasons, clearly.
// just tack on enough of U+200B ZERO WIDTH SPACEs at the end. // That all seems very questionable, and isn't even documented anywhere. So to *make it* accept such valid input,
if (str.Length < 2) // just tack on enough of U+200B ZERO WIDTH SPACEs at the end. After making sure to trim whitespace.
return str.PadRight(2, '\u200B'); string trimmed = str.Trim();
if (trimmed.Length < 2)
return trimmed.PadRight(2, '\u200B');
if (Encoding.UTF8.GetByteCount(str) <= 128) if (Encoding.UTF8.GetByteCount(str) <= 128)
return str; return str;