support Unicode IDs in whitelist settings

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2026-07-27 20:35:11 +08:00
parent b0b1fa7ff9
commit c0062a94e8

View File

@@ -362,11 +362,11 @@ void changeIdWhiteList({Function()? callback}) async {
.split(RegExp(r"[\s,;\n]+"))
.where((e) => e.isNotEmpty)
.toList();
// test id, wildcards '*' and '?' are allowed;
// '@' '.' ':' '/' '[' ']' occur in cross-server IDs and WebSocket URIs
final idMatch = RegExp(r"^[a-zA-Z0-9_*?@.:/\[\]-]+$");
// Separators are handled above; allow all other Unicode characters.
for (final id in ids) {
if (!idMatch.hasMatch(id)) {
final hasControlCharacters = id.runes.any(
(char) => char <= 0x1f || (char >= 0x7f && char <= 0x9f));
if (hasControlCharacters) {
msg = "${translate("Invalid ID")} $id";
setState(() {
isInProgress = false;