Skip to content

Conversation

slurmlord
Copy link

This change introduces an extra validation of player names before they are allowed to join a network game.
Specifically, player names containing , ; or : are denied, as they will cause trouble with the parsing of the string representation of the GameInfo. This set of characters mirrors the set of disallowed characters in https://github.com/TheSuperHackers/GeneralsGameCode/blob/dd2bb780a9226186e1d1ffe0dc60fc8000134117/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp#L861C1-L869C1

The player attempting to join will be presented with a "duplicate name" error, hinting that the name needs to be changed, as we can't introduce a new error type and retain retail compatibility.

Copy link

@OmniBlade OmniBlade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me.

@xezon xezon added Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker Network Anything related to network, servers Gen Relates to Generals ZH Relates to Zero Hour labels Sep 19, 2025
xezon
xezon previously approved these changes Sep 20, 2025
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more thoughts after taking another look.

// should not be in a player name. It should also not consist of only space characters.
if (canJoin)
{
constexpr WideChar IllegalNameChars[] = L",:;|\f\n\r\t\v";
Copy link

@xezon xezon Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the pipe character disallowed? I created a network match and was able to match 2 players with pipes (before this change). The pipe character is popular to separate clan names.

shot_20250920_112024_1

shot_20250920_112127_2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was included via a suggestion, any thoughts on this @roossienb?.
I think it would be OK to allow pipe for the parsing functionality at least - as far as I know it's ,:; that would mess up the string splitting.

Copy link

@xezon xezon Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roossienb asked if pipe was a problem. It is not after testing it.

// should not be in a player name. It should also not consist of only space characters.
if (canJoin)
{
constexpr WideChar IllegalNameChars[] = L",:;|\f\n\r\t\v";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of banning \f\n\r\t\v, how about banning all characters less than 32 ? That includes all control characters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense. As these are wide chars, are there other values or sequences beyond the traditional ASCII control characters that we should consider as well?

Copy link

@xezon xezon Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs testing. I just tested Network lobby with nickname öäü and it triggered Asserts in Debug, but otherwise worked.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, testing is definitely needed here.
I was thinking of things like Surrogate pairs and Unicode special characters that will require a lot more validation/handling that what is proposed in this PR right now.
Should we limit names to only characters in the BMP for example? Require the string to be normalized to a specific normalization form?

if (canJoin)
{
constexpr WideChar IllegalNameChars[] = L",:;|\f\n\r\t\v";
const Bool containsIllegalChars = wcscspn(msg->name, IllegalNameChars);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can simplify further to wcscspn(msg->name, L",:;|\f\n\r\t\v");

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also be... != wcslen(msg->name)

reply.GameNotJoined.playerIP = senderIP;
canJoin = false;

DEBUG_LOG(("LANAPI::handleRequestJoin - join denied because of illegal characters in the player name."));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code only affects LAN lobby, correct? If so, does this need to be replicated anywhere in Online Lobby code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen the online lobby code use the string representation of the GameInfo, which is the root of this problem. On the other hand I haven't looked really closely at the online lobby code either.
There might be 2 cases here:

  • Excluding ;:, because it causes trouble for the string parsing. If the online lobby does not use string parsing it strictly does not need to be replicated, other than maybe for consistency across the two lobbies.
  • Control characters and maybe other troublesome characters that could cause issues in the UI or other representations. These ones I think would be beneficial to replicate.

@xezon xezon changed the title bugfix(network): Deny players with invalid names from joining game bugfix(network): Deny players with invalid names from joining a LAN game room Sep 20, 2025
@xezon xezon dismissed their stale review September 21, 2025 16:31

A few more comments.

@xezon
Copy link

xezon commented Sep 30, 2025

Will this see another revision or is this final?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker Network Anything related to network, servers ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants