mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
fix(Scripts/Commands): Prevent crash if you use doublequotes in go cr… (#20012)
fix(Scripts/Commands): Prevent crash if you use doublequotes in go creature name * closes https://github.com/azerothcore/azerothcore-wotlk/issues/20010
This commit is contained in:
@@ -123,7 +123,14 @@ public:
|
|||||||
if (!name.data())
|
if (!name.data())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1" , name.data());
|
// Make sure we don't pass double quotes into the SQL query. Otherwise it causes a MySQL error
|
||||||
|
std::string str = name.data(); // Making subtractions to the last character does not with in string_view
|
||||||
|
if (str.front() == '"')
|
||||||
|
str = str.substr(1);
|
||||||
|
if (str.back() == '"')
|
||||||
|
str = str.substr(0, str.size() - 1);
|
||||||
|
|
||||||
|
QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1", str);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
handler->SendErrorMessage(LANG_COMMAND_GOCREATNOTFOUND);
|
handler->SendErrorMessage(LANG_COMMAND_GOCREATNOTFOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user