mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Improve skin name validation error message (Closed #8300)
This commit is contained in:
parent
43c03c4d54
commit
8b0b09fffd
|
@ -1,5 +1,6 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <base/log.h>
|
||||
#include <base/math.h>
|
||||
#include <base/system.h>
|
||||
|
||||
|
@ -480,9 +481,8 @@ void CMenus::Con_AddFavoriteSkin(IConsole::IResult *pResult, void *pUserData)
|
|||
const char *pStr = pResult->GetString(0);
|
||||
if(!CSkin::IsValidName(pStr))
|
||||
{
|
||||
char aError[IConsole::CMDLINE_LENGTH + 64];
|
||||
str_format(aError, sizeof(aError), "Favorite skin name '%s' is not valid", pStr);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "menus/settings", aError);
|
||||
log_error("menus/settings", "Favorite skin name '%s' is not valid", pStr);
|
||||
log_error("menus/settings", "%s", CSkin::m_aSkinNameRestrictions);
|
||||
return;
|
||||
}
|
||||
pSelf->m_SkinFavorites.emplace(pStr);
|
||||
|
|
|
@ -83,6 +83,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
if(!CSkin::IsValidName(aSkinName))
|
||||
{
|
||||
log_error("skins", "Skin name is not valid: %s", aSkinName);
|
||||
log_error("skins", "%s", CSkin::m_aSkinNameRestrictions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ public:
|
|||
|
||||
const char *GetName() const { return m_aName; }
|
||||
|
||||
// has to be kept in sync with m_aSkinNameRestrictions
|
||||
static bool IsValidName(const char *pName)
|
||||
{
|
||||
if(pName[0] == '\0' || str_length(pName) >= (int)sizeof(CSkin("").m_aName))
|
||||
|
@ -171,6 +172,7 @@ public:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
static constexpr char m_aSkinNameRestrictions[] = "Skin names must be valid filenames shorter than 24 characters.";
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue