Skip to content
Permalink
Browse files

Forbid slashes in stored expression labels labels

... because labels become part of the QSettings key
  • Loading branch information
elpaso committed Dec 17, 2019
1 parent 403972d commit 0abb48124991135df13b9b8d1054f982d4c466d3
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/gui/qgsexpressionstoredialog.cpp
@@ -17,9 +17,19 @@ QgsExpressionStoreDialog::QgsExpressionStoreDialog( const QString &label, const
saveBtn->setEnabled( false );
connect( mLabel, &QLineEdit::textChanged, this, [ = ]( const QString & text )
{
QString errorMessage;
if ( mExistingLabels.contains( text ) )
{
errorMessage = tr( "A stored expression with this name already exists" );
}
else if ( text.contains( '/' ) || text.contains( '\\' ) )
{
errorMessage = tr( "Labels cannot contain slashes (/ or \\)" );
}
if ( ! errorMessage.isEmpty() )
{
mValidationError->show();
mValidationError->setText( errorMessage );
saveBtn->setEnabled( false );
}
else
@@ -28,6 +38,9 @@ QgsExpressionStoreDialog::QgsExpressionStoreDialog( const QString &label, const
saveBtn->setEnabled( true );
}
} );
mLabel->setText( label );
// No slashes in labels!
QString labelFixed { label };
labelFixed.remove( '/' ).remove( '\\' );
mLabel->setText( labelFixed );
}

0 comments on commit 0abb481

Please sign in to comment.
You can’t perform that action at this time.