Skip to content

Comments

Prevent illegal server info from GUI#1804

Closed
pljones wants to merge 1 commit intojamulussoftware:masterfrom
pljones:bugfix/avoid-semicolons-in-serverinfo-gui
Closed

Prevent illegal server info from GUI#1804
pljones wants to merge 1 commit intojamulussoftware:masterfrom
pljones:bugfix/avoid-semicolons-in-serverinfo-gui

Conversation

@pljones
Copy link
Collaborator

@pljones pljones commented Jun 1, 2021

No description provided.

@pljones pljones force-pushed the bugfix/avoid-semicolons-in-serverinfo-gui branch 2 times, most recently from ff4c045 to 3f01ec0 Compare June 3, 2021 07:34
@pljones pljones requested review from a team, ann0see and softins and removed request for a team and ann0see June 3, 2021 19:02
Copy link
Member

@softins softins left a comment

Choose a reason for hiding this comment

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

Comments made from reading, without trying to compile and execute.

BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ),
BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) )
BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) ),
reSvrInfoIllegal ( QRegExp ( "[!;\n]*" ) )
Copy link
Member

Choose a reason for hiding this comment

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

Is the ! an excluded character (don't allow !, ; or \n), or an attempt to invert the character class? If the latter, it should be ^.

This RE seems to be used for two conflicting purposes:

  • When used to define a QRegExpValidator and applied to an edit box, it should be a RE that matches a valid input. So it would be [^;\n]* (or [^!;\n]* if the intent is also to exclude !), to which the validator adds implicit ^ and $ at the start and end respectively.
  • When used by QString::remove(), it should be the characters to remove, and so should be [;\n] (or [!;\n]), which the opposite logic to the validator, and also the * is not needed as QString::remove() removes every occurrence anyway.

Copy link
Member

Choose a reason for hiding this comment

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

! does't seem to be an invalid character (at least I doubt it's a problem). Waiting on @pljones

Copy link
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.

I'd meant "!" to be "^" at one point...


edtServerName->setAccessibleName ( tr ( "Server name line edit" ) );
const QRegExpValidator validatorServerName ( reSvrInfoIllegal, this );
edtServerName->setValidator ( &validatorServerName );
Copy link
Member

Choose a reason for hiding this comment

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

See above

{
// apply new setting to the server and update it
pServer->SetServerName ( strNewName );
pServer->SetServerName ( QString ( strNewName ).remove ( reSvrInfoIllegal ) );
Copy link
Member

Choose a reason for hiding this comment

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

See above.

src/settings.h Outdated
{
public:
CServerSettings ( CServer* pNSerP, const QString& sNFiName ) : CSettings(), pServer ( pNSerP )
CServerSettings ( CServer* pNSerP, const QString& sNFiName ) : CSettings(), pServer ( pNSerP ), reSvrInfoIllegal ( QRegExp ( "[!\n;]" ) )
Copy link
Member

Choose a reason for hiding this comment

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

See comment above for serverdlg.cpp. I realise this particular RE is only used for QString::remove(), which would imply you do actually intend to remove ! characters too. (?)

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

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

Was this PR raised to remain consistent with the CLI (which doesn't support \n and ;) or is it because these characters are problematic in any other way? Read the context: #1799 (comment)

BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ),
BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) )
BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) ),
reSvrInfoIllegal ( QRegExp ( "[!;\n]*" ) )
Copy link
Member

Choose a reason for hiding this comment

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

! does't seem to be an invalid character (at least I doubt it's a problem). Waiting on @pljones

@pljones pljones force-pushed the bugfix/avoid-semicolons-in-serverinfo-gui branch 2 times, most recently from 09010c4 to 876e1d9 Compare June 5, 2021 11:14
@pljones
Copy link
Collaborator Author

pljones commented Jun 5, 2021

Hopefully it should be a lot better today.

(I tested this one, too...)

@pljones pljones force-pushed the bugfix/avoid-semicolons-in-serverinfo-gui branch from 58450dc to 95133d2 Compare June 7, 2021 07:37
@pljones
Copy link
Collaborator Author

pljones commented Jun 12, 2021

Going with a different approach, so this solution isn't needed.

@pljones pljones closed this Jun 12, 2021
@pljones pljones deleted the bugfix/avoid-semicolons-in-serverinfo-gui branch June 12, 2021 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants