Raised This Month: $32 Target: $400
 8% 

[CS:GO] UTF8 validation - clientname


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 11-20-2020 , 14:55   [CS:GO] UTF8 validation - clientname
Reply With Quote #1

Does someone knows how to validate only UTF-8 strings? I want to allow only characters available on console, panels and hud messages. It seems that csgo doesn't support non utf8 characters there.

PHP Code:
bool IsMBCharValid(const char[] mbchar,int numbytes)
{
    
/*
    * A blacklist of unicode characters.
    * Mostly a variation of zero-width and spaces.
    */
    
int wchar UTF8ToWChar(mbcharnumbytes);

    if (
wchar == -1)
    {
        return 
false;
    }
}

int UTF8ToWChar(const char[] mbchar,int numbytes)
{
    static const 
int mask[] = { 00x7F0x1F0x0F0x070x030x01 };

    if (
numbytes 6)
    {
        return -
1;
    }

    
// First byte minus length tag
    
int wchar = (mbchar[0] & mask[numbytes]);

    for (
int i 1numbytesi++)
    {
        
// Subsequent bytes must start with 10
        
if ((mbchar[i] & 0xC0) != 0x80)
        {
            return -
1;
        }

        
wchar <<= 6// 6 bits of data in each subsequent byte
        
wchar |= (mbchar[i] & 0x3F);
    }

    return 
wchar;

This is from smac_client and it doesn't do what I want. From what I know UTF-8 chars have max 4 bytes.
__________________
Ilusion9 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-22-2020 , 14:58   Re: [CS:GO] UTF8 validation - clientname
Reply With Quote #2

Those characters you are talking about, are also UTF-8.

You can separate ANSI / Multibyte character by calling GetCharBytes function.

Personally, I'm filtering nickname characters by removing all UTF-8 (that's possibly not correct).
+ remove all chars with code < 32.

If you look in Client Name Fixer by @CrazyHackGUT, he uses a technique of removing all characters that have a char byte length > 2. And, that's possibly a correct way, you are asking about.

For reference, here is a plugin I'm using (that's for L4D).
Attached Files
File Type: sp Get Plugin or Get Source (sm_name_normalizer.sp - 121 views - 3.3 KB)
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode