mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-29 22:47:14 +00:00
fix(settings): reject spaces, '\' and control chars in URI path settings
webBasePath, subPath, subJsonPath and subClashPath are URL paths, so '/' stays allowed, but spaces, backslashes and control characters break routing. Strip them as you type (shared sanitizePath helper, now also applied to the panel base path) and reject them on save in AllSetting.CheckValid so direct API callers are covered too.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
export function sanitizePath(input: string): string {
|
||||
let out = '';
|
||||
for (const ch of String(input ?? '')) {
|
||||
const code = ch.charCodeAt(0);
|
||||
if (ch === ':' || ch === '*' || ch === ' ' || ch === '\\' || code < 0x20 || code === 0x7f) continue;
|
||||
out += ch;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function normalizePath(input: string): string {
|
||||
let p = input || '/';
|
||||
if (!p.startsWith('/')) p = '/' + p;
|
||||
if (!p.endsWith('/')) p += '/';
|
||||
p = p.replace(/\/+/g, '/');
|
||||
return p;
|
||||
}
|
||||
Reference in New Issue
Block a user