# HG changeset patch # User Wuzzy # Date 1556226065 -7200 # Node ID e239378a94004b37b1cccefc6983533852ceff49 # Parent 5443e5e0faa36bc18a8cf8560974d3c1fc8157bf Prevent entering “/”, “\” and “:” in team and scheme names. The name of teams and schems is saved in the file name itself, so these characters would cause trouble as they are used in path names in Linux and Windows. diff -r 5443e5e0faa3 -r e239378a9400 ChangeLog.txt --- a/ChangeLog.txt Thu Apr 25 21:25:16 2019 +0200 +++ b/ChangeLog.txt Thu Apr 25 23:01:05 2019 +0200 @@ -93,6 +93,7 @@ + More intelligent automatic mission selection in campaign screen * Fix force-locked schemes getting unlocked when changing map types * Fix possible to select background-only or hidden themes indirectly by changing map type + * Disallow slash, backslash and colon characters in team and scheme names Sounds and voicepacks: + sndYoohoo has been split to sndYoohoo and sndKiss diff -r 5443e5e0faa3 -r e239378a9400 QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Thu Apr 25 21:25:16 2019 +0200 +++ b/QTfrontend/hwconsts.cpp.in Thu Apr 25 23:01:05 2019 +0200 @@ -34,6 +34,8 @@ QString * cRevisionString = new QString("${HEDGEWARS_REVISION}"); QString * cHashString = new QString("${HEDGEWARS_HASH}"); +// For disallowing some characters that would screw up file name +QString * cSafeFileNameRegExp = new QString("[^:/\\\\]*"); QDir * bindir = new QDir(); QDir * cfgdir = new QDir(); diff -r 5443e5e0faa3 -r e239378a9400 QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Thu Apr 25 21:25:16 2019 +0200 +++ b/QTfrontend/hwconsts.h Thu Apr 25 23:01:05 2019 +0200 @@ -28,6 +28,7 @@ extern QString * cRevisionString; extern QString * cHashString; extern QString * cDataDir; +extern QString * cSafeFileNameRegExp; extern QDir * bindir; extern QDir * cfgdir; diff -r 5443e5e0faa3 -r e239378a9400 QTfrontend/ui/page/pageeditteam.cpp --- a/QTfrontend/ui/page/pageeditteam.cpp Thu Apr 25 21:25:16 2019 +0200 +++ b/QTfrontend/ui/page/pageeditteam.cpp Thu Apr 25 23:01:05 2019 +0200 @@ -28,9 +28,12 @@ #include #include #include +#include +#include #include "SquareLabel.h" #include "HWApplication.h" #include "keybinder.h" +#include "hwconsts.h" #include "physfs.h" #include "DataManager.h" @@ -129,6 +132,9 @@ TeamNameEdit->setMaxLength(64); TeamNameEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); TeamNameEdit->setStyleSheet("QLineEdit { padding: 6px; }"); + QRegExp rx(*cSafeFileNameRegExp); + QRegExpValidator * val = new QRegExpValidator(rx, TeamNameEdit); + TeamNameEdit->setValidator(val); GBTLayout->addWidget(TeamNameEdit, 0, 1, 1, 2); vbox2->addWidget(GBoxTeam); diff -r 5443e5e0faa3 -r e239378a9400 QTfrontend/ui/page/pagescheme.cpp --- a/QTfrontend/ui/page/pagescheme.cpp Thu Apr 25 21:25:16 2019 +0200 +++ b/QTfrontend/ui/page/pagescheme.cpp Thu Apr 25 23:01:05 2019 +0200 @@ -26,7 +26,10 @@ #include #include #include +#include +#include +#include "hwconsts.h" #include "gameSchemeModel.h" #include "pagescheme.h" #include "FreqSpinBox.h" @@ -517,6 +520,9 @@ L_name->setText(QLabel::tr("Scheme Name:")); LE_name = new QLineEdit(this); + QRegExp rx(*cSafeFileNameRegExp); + QRegExpValidator * val = new QRegExpValidator(rx, LE_name); + LE_name->setValidator(val); LE_name->setWhatsThis(tr("Name of this scheme")); gl->addWidget(LE_name,15,1,1,5); diff -r 5443e5e0faa3 -r e239378a9400 QTfrontend/ui/widget/selectWeapon.cpp --- a/QTfrontend/ui/widget/selectWeapon.cpp Thu Apr 25 21:25:16 2019 +0200 +++ b/QTfrontend/ui/widget/selectWeapon.cpp Thu Apr 25 23:01:05 2019 +0200 @@ -31,6 +31,9 @@ #include #include #include +#include +#include + #include QImage getAmmoImage(int num) @@ -205,6 +208,9 @@ //pLayout->setRowStretch(5, 100); m_name = new QLineEdit(this); + QRegExp rx(*cSafeFileNameRegExp); + QRegExpValidator* val = new QRegExpValidator(rx, m_name); + m_name->setValidator(val); pageLayout->addWidget(m_name, i, 0, 1, 5); } diff -r 5443e5e0faa3 -r e239378a9400 share/hedgewars/Data/Names/README.md --- a/share/hedgewars/Data/Names/README.md Thu Apr 25 21:25:16 2019 +0200 +++ b/share/hedgewars/Data/Names/README.md Thu Apr 25 23:01:05 2019 +0200 @@ -42,7 +42,9 @@ * Each hog of this team gets a random hat of this list. Repeat a hat name to jack up its probability. -Each team is again separated by a separator line. +Each team is again separated by a separator line. The team name must not +contain characters that would be forbidden in a file name (such as “/”, +“\” or “:”). At the end of the final team, this line must be written (without the spaces):