mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: #6921, allow square brackets in usernames
This commit is contained in:
@@ -321,7 +321,7 @@
|
|||||||
|
|
||||||
if (typeof target === 'number') {
|
if (typeof target === 'number') {
|
||||||
return String.fromCharCode(target);
|
return String.fromCharCode(target);
|
||||||
} else if (typeof target === 'string') {
|
} if (typeof target === 'string') {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
isUserNameValid: function (name) {
|
isUserNameValid: function (name) {
|
||||||
return (name && name !== '' && (/^['"\s\-+.*0-9\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(name)));
|
return (name && name !== '' && (/^['"\s\-+.*[\]0-9\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(name)));
|
||||||
},
|
},
|
||||||
|
|
||||||
isPasswordValid: function (password) {
|
isPasswordValid: function (password) {
|
||||||
@@ -487,7 +487,7 @@
|
|||||||
}
|
}
|
||||||
if (n > 999999) {
|
if (n > 999999) {
|
||||||
return (n / 1000000).toFixed(1) + 'm';
|
return (n / 1000000).toFixed(1) + 'm';
|
||||||
} else if (n > 999) {
|
} if (n > 999) {
|
||||||
return (n / 1000).toFixed(1) + 'k';
|
return (n / 1000).toFixed(1) + 'k';
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
|||||||
@@ -51,10 +51,16 @@ describe('Utility Methods', function () {
|
|||||||
var username = "John\"'-. Doeäâèéë1234";
|
var username = "John\"'-. Doeäâèéë1234";
|
||||||
assert(utils.isUserNameValid(username), 'invalid username');
|
assert(utils.isUserNameValid(username), 'invalid username');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects empty string', function () {
|
it('rejects empty string', function () {
|
||||||
var username = '';
|
var username = '';
|
||||||
assert.equal(utils.isUserNameValid(username), false, 'accepted as valid username');
|
assert.equal(utils.isUserNameValid(username), false, 'accepted as valid username');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('accepts square brackets', function () {
|
||||||
|
var username = '[best clan] julian';
|
||||||
|
assert(utils.isUserNameValid(username), 'invalid username');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('email validation', function () {
|
describe('email validation', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user