fix: reject raw probe target whitespace

This commit is contained in:
sagitchu
2026-05-01 23:54:31 +08:00
parent d97d91801d
commit 0f3242bf11
+5 -3
View File
@@ -157,17 +157,19 @@ export const validateTunnelForm = (
errors.trafficRatio = "流量倍率须大于0,支持小数(如 0.5)";
}
const probeHost = (form.probeTargetHost || "").trim();
const rawProbeHost = form.probeTargetHost || "";
const probeHost = rawProbeHost.trim();
const probePortInput = form.probeTargetPort;
const probePort = Number(probePortInput ?? 0);
const hasProbeHostInput = rawProbeHost.length > 0;
const hasProbePort = probePortInput != null && probePortInput !== 0;
if (probeHost || hasProbePort) {
if (hasProbeHostInput || hasProbePort) {
if (!probeHost) {
errors.probeTargetHost = "请输入测试目标 Host";
} else if (
probeHost.includes("://") ||
/[\s/?#]/.test(probeHost) ||
/[\s/?#]/.test(rawProbeHost) ||
isSchemeLikeProbeHost(probeHost)
) {
errors.probeTargetHost = "Host 不能包含协议、端口、空格或路径";