NameFilter: Freaking unicode.
This commit is contained in:
parent
0f98bf718e
commit
caa37dc3fc
@ -190,7 +190,7 @@ void LoadConfig()
|
|||||||
|
|
||||||
char sError[256];
|
char sError[256];
|
||||||
RegexError iError;
|
RegexError iError;
|
||||||
g_FilterExpr = CompileRegex(sBuffer, 0, sError, sizeof(sError), iError);
|
g_FilterExpr = CompileRegex(sBuffer, PCRE_UTF8, sError, sizeof(sError), iError);
|
||||||
if(iError != REGEX_ERROR_NONE)
|
if(iError != REGEX_ERROR_NONE)
|
||||||
{
|
{
|
||||||
delete Config;
|
delete Config;
|
||||||
@ -206,7 +206,7 @@ void LoadConfig()
|
|||||||
{
|
{
|
||||||
Config.GetString(NULL_STRING, sBuffer, sizeof(sBuffer));
|
Config.GetString(NULL_STRING, sBuffer, sizeof(sBuffer));
|
||||||
|
|
||||||
Handle hRegex = CompileRegex(sBuffer, 0, sError, sizeof(sError), iError);
|
Handle hRegex = CompileRegex(sBuffer, PCRE_UTF8, sError, sizeof(sError), iError);
|
||||||
if(iError != REGEX_ERROR_NONE)
|
if(iError != REGEX_ERROR_NONE)
|
||||||
LogError("Error parsing banned filter: %s", sError);
|
LogError("Error parsing banned filter: %s", sError);
|
||||||
else
|
else
|
||||||
@ -295,23 +295,26 @@ bool FilterName(int client, char[] sName, int Length = MAX_NAME_LENGTH)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!bChanged)
|
||||||
|
bChanged = TerminateNameUTF8(sName);
|
||||||
|
|
||||||
if(bChanged)
|
if(bChanged)
|
||||||
{
|
{
|
||||||
|
TerminateNameUTF8(sName);
|
||||||
|
|
||||||
if(strlen(sName) < 2)
|
if(strlen(sName) < 2)
|
||||||
{
|
{
|
||||||
int RandomName = client % g_ReplacementNames.Length;
|
int RandomName = client % g_ReplacementNames.Length;
|
||||||
g_ReplacementNames.GetString(RandomName, sName, Length);
|
g_ReplacementNames.GetString(RandomName, sName, Length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminateNameUTF8(sName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bChanged;
|
return bChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensures that utf8 names are properly terminated
|
// ensures that utf8 names are properly terminated
|
||||||
stock void TerminateNameUTF8(char[] name)
|
stock bool TerminateNameUTF8(char[] name)
|
||||||
{
|
{
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
for(int i = 0; i < len; i++)
|
for(int i = 0; i < len; i++)
|
||||||
@ -322,10 +325,11 @@ stock void TerminateNameUTF8(char[] name)
|
|||||||
if(len - i < bytes)
|
if(len - i < bytes)
|
||||||
{
|
{
|
||||||
name[i] = '\0';
|
name[i] = '\0';
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
i += bytes - 1;
|
i += bytes - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user