diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp
index 3f087987..55cb330e 100644
--- a/cockatrice/src/window_main.cpp
+++ b/cockatrice/src/window_main.cpp
@@ -476,9 +476,22 @@ QString MainWindow::extractInvalidUsernameMessage(QString &in)
"";
if (rules.size() == 9) {
- if (rules.at(7).size() > 0)
- out += "
" + tr("can not contain any of the following words: %1").arg(rules.at(7).toHtmlEscaped()) +
- "";
+ if (rules.at(7).size() > 0) {
+ QString words = rules.at(7).toHtmlEscaped();
+ if (words.startsWith("\n")) {
+ out += tr("no unacceptable language as specified by these server rules:",
+ "note that the following lines will not be translated");
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ for (QString &line : words.split("\n", Qt::SkipEmptyParts)) {
+#else
+ for (QString &line : words.split("\n", QString::SkipEmptyParts)) {
+#endif
+ out += "" + line + "";
+ }
+ } else {
+ out += "" + tr("can not contain any of the following words: %1").arg(words) + "";
+ }
+ }
if (rules.at(8).size() > 0)
out += "" +
diff --git a/servatrice/servatrice.ini.example b/servatrice/servatrice.ini.example
index 93dee245..8a214f39 100644
--- a/servatrice/servatrice.ini.example
+++ b/servatrice/servatrice.ini.example
@@ -127,6 +127,16 @@ allowpunctuationprefix=false
; "admin,user,name"
disallowedwords="admin"
+; Overwrite the words shown to the user when they enter a wrong username,
+; use \n to start a new line. Neither the real wordlist nor the disallowed
+; expressions will be sent to the user if this is set.
+; In the old versions of the client this list will be prefaced with
+; "can not contain any of the following words:"
+; example:
+;displaydisallowedwords="no attempts at impersonating staff\nno unparliamentary language\nno references to controversial figures\nstaff reserves the right to remove accounts deemed inappropriate"
+; Setting it to nothing will simply hide the list:
+;displaydisallowedwords=
+
; Disallow usernames matching these regular expressions. This list is comma
; separated, e.g. "\\w+\\d+,\\d{2}user", hence you cannot use commas in your
; expressions. Backslashes must be escaped, so `\w+\d+` becomes `\\w+\\d+`.
diff --git a/servatrice/src/servatrice_database_interface.cpp b/servatrice/src/servatrice_database_interface.cpp
index a0c4a942..bcc98f4d 100644
--- a/servatrice/src/servatrice_database_interface.cpp
+++ b/servatrice/src/servatrice_database_interface.cpp
@@ -153,7 +153,16 @@ bool Servatrice_DatabaseInterface::usernameIsValid(const QString &user, QString
QStringList disallowedWords = disallowedWordsStr.split(",", QString::SkipEmptyParts);
#endif
disallowedWords.removeDuplicates();
- QString disallowedRegExpStr = settingsCache->value("users/disallowedregexp", "").toString();
+ QVariant displayDisallowedWords = settingsCache->value("users/displaydisallowedwords");
+ QString disallowedRegExpStr;
+ if (displayDisallowedWords.isValid()) {
+ disallowedWordsStr = displayDisallowedWords.toString().trimmed();
+ if (!disallowedWordsStr.isEmpty()) {
+ disallowedWordsStr.prepend("\n");
+ }
+ } else {
+ disallowedRegExpStr = settingsCache->value("users/disallowedregexp", "").toString();
+ }
error = QString("%1|%2|%3|%4|%5|%6|%7|%8|%9")
.arg(minNameLength)