Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
how do i make @ to work with Chinese username

this is the link http://15min.cc/index.php?p=/discussion/43/test-user#latest
can anyone take a look and help me
0
Best Answer
-
chuck911 ✭
@jeongwee http://vanillaforums.org/addon/chinesepreference-plugin just install this plugin !
Chinese Preference 中文增强补丁 0.1b
7
Answers
Try those two changes https://github.com/vanillaforums/Garden/pull/1653 and https://github.com/vanillaforums/Garden/pull/1654
@R_J
=.= sry ,my english sucks..... where shud i click ...and where shud i put the file.
add this right?
but my lines looks diffrent
im 2.1b1
how do i do now..................
@R_J is it here?
exchange
'/(?:^|[\s,\.>])@(\w{3,20})\b/i',
by'/(?:^|[\s,\.>])@('.ValidateUsernameRegex().')\b/i',
inlibrary/core/functions.general.php
@R_J still same , not working with @ Chinese words..................
According to that: https://github.com/vanillaforums/Garden/pull/1653/files
change in file
library/core/class.format.php
'/(^|[\s,\.>])@(\w{1,50})\b/i', //{3,20}
with'/(^|[\s,\.>])@('.ValidateUsernameRegex().')\b/i', //{3,20}
@R_J
my file doesnt have line
its 2.1b1 here.
Search for that in library/core/class.format.php:
@R_J i changed my library/core/functions.general.php file back. shud i change both? if only change
i have done change it,and it still not working with chinese words.
You have to change both files. Try to understand what you are doing ;-)
'/(^|[\s,\.>])@('.ValidateUsernameRegex().')\b/i',
it uses the functionValidateUsernameRegex
.$Configuration['Garden']['User']['ValidationRegex'] = '\d\w_';
The changes to the 1. functions.general.php 2. class.format.php and 3. config.ini should be enaugh to solve your problem
i have done 1-5 steps alrdy.
1.the file you are looking at has a regular expression that searches for @username, but username is not allowed to contain chinese symbols.
2.When you change it to
, it uses the function ValidateUsernameRegex.3.You can find the function here : https://github.com/vanillaforums/Garden/search?q=ValidateUsernameRegex&ref=cmdform
4.there you can see that it compares usernames to C("Garden.User.ValidationRegex")
5.so you have to make a config setting $Configuration['Garden']['User']['ValidationRegex'] = '\d\w_';
im sure i did right by follow the steps,and it still havnt solved the problem.
so the "6.now google for a regex that allows all chinese symbols and add that to the above config file."is my last hope:(
what keyword shud i search? "regex chinese symbols?"i don really know wat shud i do ...i have searched it and nothing is looks like
im confusedI do not know how chinese symbols are called. There must be a chinese word for it. Look for that word and "regex". I'll try for myself but your chances are bigger than mine, I'd bet...
that is the most important one because that is what the regex will check against. I recommend unicode
try using this in the config values for the regex
$Configuration['Garden']['User']['ValidationRegex'] = '/^([\p{L}\p{N}\p{Pd}\p{Pc}\p{Lm}\p{M}]{3,20}+)?$/';
regex= regular expressions
http://www.regular-expressions.info/unicode.html
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
If the string is encoded in UTF-8, this regex will probably match all Chinese characters:
Add Pages to Vanilla with the Basic Pages app
Seems to be complicated: chinese symbols are unicode characters and they require a special switch, but you can not set that in config.
That is the regex you need in your config:
' [\x{4E00}-\x{9FA5}]\d\w_'
(at least that's what google told meBut you also have to go to the lines that you've already changed in functions.general.php and class.format.php and change
/i'
(end of the line) to'/iu'
I'm no expert with regular expressions. Try to sign in with a chinese user name after you've made the changes!
I'm third - I should have updated the thread before posting...
Wouldn't the switch be a problem?
@vrijvlinder @Shadowdare
the codes
and
just made the discussion and comments disappear.
Regex are a bitch... :-D