mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FIX: Stop autocomplete for invalid usernames. (#7005)
This commit is contained in:
parent
f8b70f4ca3
commit
a423a9383f
@ -121,6 +121,10 @@ export default function userSearch(options) {
|
||||
topicId = options.topicId,
|
||||
group = options.group;
|
||||
|
||||
if (/[^\w.-]/.test(term)) {
|
||||
term = "";
|
||||
}
|
||||
|
||||
if (oldSearch) {
|
||||
oldSearch.abort();
|
||||
oldSearch = null;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import userSearch from "discourse/lib/user-search";
|
||||
import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
|
||||
|
||||
QUnit.module("lib:user-search", {
|
||||
beforeEach() {
|
||||
@ -71,3 +72,8 @@ QUnit.test("it strips @ from the beginning", async assert => {
|
||||
let results = await userSearch({ term: "@Team" });
|
||||
assert.equal(results[results.length - 1]["name"], "team");
|
||||
});
|
||||
|
||||
QUnit.test("it does not search for invalid usernames", async assert => {
|
||||
let results = await userSearch({ term: "foo, " });
|
||||
assert.equal(results, CANCELLED_STATUS);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user