From 23c8b7dabf8f2205390a6f796529e790771db22e Mon Sep 17 00:00:00 2001 From: quank123wip Date: Thu, 25 Apr 2019 22:19:54 +0800 Subject: [PATCH] add username_regex --- config-example.json | 3 ++- utility.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config-example.json b/config-example.json index 2c5a90b..761e168 100644 --- a/config-example.json +++ b/config-example.json @@ -121,5 +121,6 @@ "type": "like-google-fonts", "url": "https://fonts.loli.net" }, - "no_cdn": false + "no_cdn": false, + "username_regex": "^[a-zA-Z0-9\\-\\_]+$" } diff --git a/utility.js b/utility.js index f2524fa..1288106 100644 --- a/utility.js +++ b/utility.js @@ -255,7 +255,7 @@ module.exports = { return md5.digest('hex'); }, isValidUsername(s) { - return /^[a-zA-Z0-9\-\_]+$/.test(s); + return RegExp(syzoj.config.username_regex).test(s); }, locks: [], lock(key, cb) {