sanitize MIDI parser (#38806)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
slarticodefast
2025-07-07 14:23:45 +02:00
committed by GitHub
parent 5f7db3b151
commit a03c35a9bc
3 changed files with 37 additions and 6 deletions

View File

@@ -156,6 +156,15 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
return;
}
foreach (var t in msg.Tracks)
{
// Remove any control characters that may be part of the midi file so they don't end up in the admin logs.
t?.SanitizeFields();
// Truncate any track names too long.
t?.TruncateFields(_cfg.GetCVar(CCVars.MidiMaxChannelNameLength));
}
var tracksString = string.Join("\n",
msg.Tracks
.Where(t => t != null)
@@ -166,12 +175,6 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
LogImpact.Low,
$"{ToPrettyString(args.SenderSession.AttachedEntity)} set the midi channels for {ToPrettyString(uid)} to {tracksString}");
// Truncate any track names too long.
foreach (var t in msg.Tracks)
{
t?.TruncateFields(_cfg.GetCVar(CCVars.MidiMaxChannelNameLength));
}
activeInstrument.Tracks = msg.Tracks;
Dirty(uid, activeInstrument);