Skip to content

bugfix(network): Deny players with invalid names from joining a LAN game room#1595

Merged
xezon merged 2 commits into
TheSuperHackers:mainfrom
slurmlord:deny-invalid-lanplayernames
Nov 14, 2025
Merged

bugfix(network): Deny players with invalid names from joining a LAN game room#1595
xezon merged 2 commits into
TheSuperHackers:mainfrom
slurmlord:deny-invalid-lanplayernames

Conversation

@slurmlord

Copy link
Copy Markdown

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.

@OmniBlade OmniBlade left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks okay to me.

Comment thread Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
@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
Comment thread Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
xezon
xezon previously approved these changes Sep 20, 2025

@xezon xezon left a comment

Copy link
Copy Markdown

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.

Comment thread Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
// 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
Copy Markdown

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
Copy Markdown
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?

@xezon xezon Sep 24, 2025

Copy link
Copy Markdown

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
Copy Markdown
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?

Comment thread Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
Comment thread Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
@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

xezon commented Sep 30, 2025

Copy link
Copy Markdown

Will this see another revision or is this final?

@xezon xezon added the Approved Pull Request was approved label Oct 21, 2025
@xezon

xezon commented Oct 25, 2025

Copy link
Copy Markdown

It would be good to get this finalized.

@slurmlord

Copy link
Copy Markdown
Author

Will this see another revision or is this final?

Sorry, I missed this comment entirely - will make another pass with limiting characters to only from the BMP.

@slurmlord

Copy link
Copy Markdown
Author

Broadened the definition of illegal and space characters:

  • Low and high surrogates are now flagged as not OK
  • All character codes below 0x20 are rejected (C0)
  • Character codes from C1 are also rejected
  • Reject line and paragraph separators
  • Consider all char codes from the Unicode Space Separator category as space

Validated with some non-ASCII player names
Screenshot From 2025-10-27 23-24-56

Verified that players with "," (example of forbidden char) in the name are denied
Screenshot From 2025-10-27 23-25-23

Comment thread Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Comment thread Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Comment thread GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
@slurmlord slurmlord force-pushed the deny-invalid-lanplayernames branch from df66d16 to 3c3c5f2 Compare November 13, 2025 19:55

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code looks mostly good.

Comment thread Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp Outdated
@xezon xezon merged commit da26e01 into TheSuperHackers:main Nov 14, 2025
17 checks passed
@slurmlord slurmlord deleted the deny-invalid-lanplayernames branch November 14, 2025 22:50
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Pull Request was approved 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.

5 participants