SMF Support > SMF 2.0.x Support

Special characters in display names?

(1/1)

Walkerneo:
The users of my Forum have discovered that they can use special characters in their names.. This has lead to some very annoying display names. How can I prevent this?


I've changed my display name to exemplify this.

Arantor:
You can't without modifying the code to do it, unfortunately I've long since forgotten exactly where to change it to prevent it in future.

Of course, you could just issue them with warnings until they get the hint - not all problems need a technical solution.

MrPhil:
For initial registration, it looks like Sources/Subs-Members.php function registerMember() is checking the input name in $regOptions['username']. Right before the comment "// !!! Separate the sprintf?" you could probably insert code to check the alphabet used (e.g., permit ASCII only) with preg_match(). If you find something in the wrong alphabet,

--- Code: ---$reg_errors[] = array('lang', 'error_invalid_characters_username');
--- End code ---

I haven't looked, but there is probably similar code somewhere to handle a change of user name. Also, there may be separate login names and display names to handle. Now that you know what to look for...

Note: be sensitive to users in non-English speaking countries, who might have a legitimate requirement to enter accented characters, and might find a restriction to use only ASCII too onerous. Even if you have trouble typing in their name, they won't necessarily! Also keep in mind what character encoding is being used, as UTF-8, Latin-n, and other alphabets have different byte values for accented characters (even, multiple bytes). If you decide to allow certain ranges of accented and non-Latin characters, this code will be encoding-sensitive and in a non-language file. That may be why such checking is not in base SMF. You're responsible for editing the file under proper encoding.

Navigation

[0] Message Index

Go to full version