Skip to content

Commit

Permalink
Strip server name's spaces from beginning and end (#3805)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha authored Oct 25, 2024
1 parent 353b6c6 commit e92702c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CMainConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ bool CMainConfig::Load()
return false;
}

// Strip spaces from beginning and end of server name
m_strServerName = SString(m_strServerName).TrimStart(" ").TrimEnd(" ");

// Grab the forced server ip(s)
GetString(m_pRootNode, "serverip", m_strServerIP);
m_strServerIP = SString(m_strServerIP).Replace(" ", "");
Expand Down

3 comments on commit e92702c

@ArranTuna
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that there's at least 2 different space symbols so this might not fix it if they use the other symbol.

@Lpsd
Copy link
Member

@Lpsd Lpsd commented on e92702c Oct 26, 2024

Choose a reason for hiding this comment

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

We could probably introduce a better "trim" method to SString using find_first_not_of and find_last_not_of with \t to find the range of valid characters and return substr.

@TheNormalnij
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to add a new namespace with our string library functions. This will help us to avoid SString in the new code

Please sign in to comment.