Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
strMinServerVersion ( "" ), // disable version check with empty version
pConnLessProtocol ( pNConLProt ),
eSvrRegStatus ( SRS_UNREGISTERED ),
iSvrRegRetries ( 0 )
iSvrRegRetries ( 0 ),
reIllegal ( "\n" )
{
// set the directory server address
SetCentralServerAddress ( sNCentServAddr );
Expand Down Expand Up @@ -87,10 +88,10 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
if ( iServInfoNumSplitItems >= 3 )
{
// [this server name]
ThisServerListEntry.strName = slServInfoSeparateParams[0].left ( MAX_LEN_SERVER_NAME );
ThisServerListEntry.strName = slServInfoSeparateParams[0].remove ( reIllegal ).left ( MAX_LEN_SERVER_NAME );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just removing \n automatically without warning the user might cause confusion. I'd give a warning on stderr and strip the new line afterwards.

Copy link
Copy Markdown
Collaborator Author

@pljones pljones Jun 5, 2021

Choose a reason for hiding this comment

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

It can go on the Wiki. It's quite difficult to get a new line into the string in the first place - I doubt people are going to use it.

You could argue truncating the server name is surprising people, and that's more commonly hit.

Copy link
Copy Markdown
Member

@ann0see ann0see Jun 5, 2021

Choose a reason for hiding this comment

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

Hmm yes that’s probably more common. Can you open an issue on the website repo to document this change (new line)? Probably that’s something for @gilgongo s Server manual.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!


// [this server city]
ThisServerListEntry.strCity = slServInfoSeparateParams[1].left ( MAX_LEN_SERVER_CITY );
ThisServerListEntry.strCity = slServInfoSeparateParams[1].remove ( reIllegal ).left ( MAX_LEN_SERVER_CITY );

// [this server country as QLocale ID]
const int iCountry = slServInfoSeparateParams[2].toInt();
Expand Down
3 changes: 3 additions & 0 deletions src/serverlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ class CServerListManager : public QObject
// count of registration retries
int iSvrRegRetries;

// Strip illegal characters
const QRegExp reIllegal;

public slots:
void OnTimerPollList();
void OnTimerPingServerInList();
Expand Down