mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-20 15:15:15 +01:00
fix(server): Add boundary check for editing host name (#1018)
* feat(localization): Add validation prompt for invalid host formats Add validation for host formats, allowing only IPv4, IPv6, and domain name formats Add regular expression validation for host format on the server editing page Update multilingual files to add the invalidHostFormat field * chore: Update dependent package versions to the latest * fix(server edit): Update the hostname regular expression to support IPv6 zone identifiers Modify the regular expression for hostname validation to add support for IPv6 zone identifiers (such as %en0)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
part of 'edit.dart';
|
||||
|
||||
/// Only permit ipv4 / ipv6 / domain chars (including IPv6 zone identifier like %en0)
|
||||
final _hostReg = RegExp(r'^[a-zA-Z0-9\.\-_:%;]+$');
|
||||
|
||||
extension _Actions on _ServerEditPageState {
|
||||
Future<void> _onTapSSHDiscovery() async {
|
||||
try {
|
||||
@@ -222,6 +225,11 @@ extension _Actions on _ServerEditPageState {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_hostReg.hasMatch(_ipController.text)) {
|
||||
context.showSnackBar(l10n.invalidHostFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_keyIdx.value == null && _passwordController.text.isEmpty) {
|
||||
final ok = await context.showRoundDialog<bool>(
|
||||
title: libL10n.attention,
|
||||
|
||||
Reference in New Issue
Block a user