You can also share your feedback on Copilot code review. Take the survey.
## Pull request overview
Adds an admin-only helper on `Connection` to send a `GAME:AWARD` command to the server to award a match winner.
**Changes:**
- Add `Connection.AwardGame(int matchID, string winnerUsername)` admin helper.
- Validate admin status and non-empty winner username before sending the command.
---
💡 <a href="/joshuafhiggins/connect4-moderator-observer/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.<br><br>You can also share your feedback on Copilot code review. [Take the survey](https://www.surveymonkey.com/r/XP6L3XJ).
winnerUsername is inserted into a colon-delimited wire format ("GAME:AWARD::"). If the username contains : it will change the segment structure and can lead to malformed commands / protocol injection. Consider trimming into a local variable and rejecting (or escaping) reserved delimiter characters like : (consistent with SendConnect, which blocks : in the client id).
var trimmedWinnerUsername = winnerUsername.Trim();
if (trimmedWinnerUsername.Contains(":")) {
GD.PushError("AwardGame: winner username contains invalid ':' character and will not be sent.");
return;
}
sendCommand("GAME", "AWARD:" + matchID + ":" + trimmedWinnerUsername);
`winnerUsername` is inserted into a colon-delimited wire format ("GAME:AWARD:<matchID>:<username>"). If the username contains `:` it will change the segment structure and can lead to malformed commands / protocol injection. Consider trimming into a local variable and rejecting (or escaping) reserved delimiter characters like `:` (consistent with `SendConnect`, which blocks `:` in the client id).
```suggestion
var trimmedWinnerUsername = winnerUsername.Trim();
if (trimmedWinnerUsername.Contains(":")) {
GD.PushError("AwardGame: winner username contains invalid ':' character and will not be sent.");
return;
}
sendCommand("GAME", "AWARD:" + matchID + ":" + trimmedWinnerUsername);
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Testing
Pull request overview
Adds an admin-only helper on
Connectionto send aGAME:AWARDcommand to the server to award a match winner.Changes:
Connection.AwardGame(int matchID, string winnerUsername)admin helper.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
@@ -211,0 +211,4 @@public void AwardGameWinner(int matchID, string winnerUsername) {if (!IsAdmin) return;if (string.IsNullOrWhiteSpace(winnerUsername)) return;sendCommand("GAME", "AWARD:" + matchID + ":" + winnerUsername.Trim());winnerUsernameis inserted into a colon-delimited wire format ("GAME:AWARD::"). If the username contains:it will change the segment structure and can lead to malformed commands / protocol injection. Consider trimming into a local variable and rejecting (or escaping) reserved delimiter characters like:(consistent withSendConnect, which blocks:in the client id).