Qt: Fix invalid characters for profiles

Change-Id: Ic44f075b2723e2d5d95e29b485791e89134315e8
Reviewed-on: https://code.wireshark.org/review/34056
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Roland Knall 2019-07-22 16:42:32 +02:00
parent 8198413514
commit 8892da8a47
1 changed files with 3 additions and 1 deletions

View File

@ -776,6 +776,7 @@ bool ProfileModel::checkNameValidity(QString name, QString *msg)
{
QString message;
bool invalid = false;
QString msgChars;
#ifdef _WIN32
/* According to https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file */
@ -786,11 +787,12 @@ bool ProfileModel::checkNameValidity(QString name, QString *msg)
for ( int cnt = 0; cnt < invalid_dir_chars.length() && ! invalid; cnt++ )
{
msgChars += invalid_dir_chars[cnt] + " ";
if ( name.contains(invalid_dir_chars[cnt]) )
invalid = true;
}
if ( invalid )
message = tr("A profile must not contain any of the following characters: %1").arg(invalid_dir_chars);
message = tr("A profile must not contain any of the following characters: %1").arg(msgChars);
if ( message.isEmpty() && ( name.startsWith('.') || name.endsWith('.') ) )
message = tr("A profile must not start or end with a period (.)");