aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/Utilities/Util.cpp2
-rw-r--r--src/server/game/Chat/Hyperlinks.cpp40
-rw-r--r--src/server/worldserver/worldserver.conf.dist12
3 files changed, 34 insertions, 20 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index 317f8c754f8..0d65f1f7f81 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -842,7 +842,7 @@ bool StringEqualI(std::string_view str1, std::string_view str2)
bool StringStartsWith(std::string_view haystack, std::string_view needle)
{
- return (haystack.rfind(needle, 0) == 0);
+ return (haystack.substr(0, needle.length()) == needle);
}
bool StringContainsStringI(std::string_view haystack, std::string_view needle)
diff --git a/src/server/game/Chat/Hyperlinks.cpp b/src/server/game/Chat/Hyperlinks.cpp
index 448ad0a4ea7..2d1711f8a21 100644
--- a/src/server/game/Chat/Hyperlinks.cpp
+++ b/src/server/game/Chat/Hyperlinks.cpp
@@ -449,6 +449,9 @@ struct LinkValidator<LinkTags::quest>
{
static bool IsTextValid(QuestLinkData const& data, std::string_view text)
{
+ if (text.empty())
+ return false;
+
if (text == data.Quest->GetLogTitle())
return true;
@@ -629,25 +632,32 @@ struct LinkValidator<LinkTags::worldmap>
}
};
-#define TryValidateAs(tagname) \
-{ \
- static_assert(LinkTags::tagname::tag() == #tagname); \
- if (info.tag == LinkTags::tagname::tag()) \
- { \
- advstd::remove_cvref_t<typename LinkTags::tagname::value_type> t; \
- if (!LinkTags::tagname::StoreTo(t, info.data)) \
- return false; \
- if (!LinkValidator<LinkTags::tagname>::IsColorValid(t, info.color)) \
- return false; \
- if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY)) \
- if (!LinkValidator<LinkTags::tagname>::IsTextValid(t, info.text)) \
- return false; \
- return true; \
- } \
+template <typename TAG>
+static bool ValidateAs(HyperlinkInfo const& info)
+{
+ std::decay_t<typename TAG::value_type> t;
+ if (!TAG::StoreTo(t, info.data))
+ return false;
+
+ int32 const severity = static_cast<int32>(sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY));
+ if (severity >= 0)
+ {
+ if (!LinkValidator<TAG>::IsColorValid(t, info.color))
+ return false;
+ if (severity >= 1)
+ {
+ if (!LinkValidator<TAG>::IsTextValid(t, info.text))
+ return false;
+ }
+ }
+ return true;
}
+#define TryValidateAs(T) do { if (info.tag == T::tag()) return ValidateAs<T>(info); } while (0)
+
static bool ValidateLinkInfo(HyperlinkInfo const& info)
{
+ using namespace LinkTags;
TryValidateAs(achievement);
TryValidateAs(apower);
TryValidateAs(azessence);
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index e4a48870af0..bf31f423c50 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -1987,10 +1987,14 @@ ChatFakeMessagePreventing = 1
#
# ChatStrictLinkChecking.Severity
# Description: Check chat messages for in-game links to spells, items, quests, etc.
-# Default: 0 - (Only verify that link format looks valid without checking the text)
-# 1 - (Check if color, entry and name don't contradict each other. For this to
-# work correctly, please assure that you have extracted locale DBCs of
-# every language specific client playing on this server)
+# -1 - (Only verify validity of link data, but permit use of custom colors)
+# Default: 0 - (Only verify that link data and color are valid without checking text)
+# 1 - (Additionally verifies that the link text matches the provided data)
+#
+# Note: If this is set to '1', you must additionally provide .dbc files for all
+# client locales that are in use on your server.
+# If any files are missing, messages with links from clients using those
+# locales will likely be blocked by the server.
ChatStrictLinkChecking.Severity = 0