Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -8,6 +8,40 @@ function sanitizeServerToken(raw) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// Canonical display-name sanitizer. index.js sanitizeDisplayName delegates to
|
||||
// this so the main create route and the node-proxy create route (nodes.js)
|
||||
// cannot drift apart.
|
||||
function sanitizeDisplayNameToken(raw) {
|
||||
let name = String(raw || "").trim();
|
||||
if (!name) return "";
|
||||
if (name.includes("..") || /[\/\\]/.test(name)) return "";
|
||||
name = name.replace(/[^\w\s\-_.]/g, "").replace(/\s+/g, " ").trim();
|
||||
if (name.length > 120) name = name.slice(0, 120).trim();
|
||||
return name;
|
||||
}
|
||||
|
||||
// adpanel:node-storage-name — mirrors the node daemon's Go sanitizeName
|
||||
// (main.go) EXACTLY: this is the filesystem namespace the node actually
|
||||
// stores servers under. The panel namespace above (sanitizeServerToken)
|
||||
// keeps leading/trailing "_" and ".", while Go TrimSpace's, collapses
|
||||
// whitespace to '-', removes [^\w\-_.] (ASCII \w = [A-Za-z0-9_]), Trim's
|
||||
// "-_." from BOTH ends, strips any remaining leading non-alphanumeric
|
||||
// characters and caps at 120 — so two distinct panel names can map to ONE
|
||||
// node directory. The create route uses this to refuse NEW collisions.
|
||||
// Keep in lockstep with main.go sanitizeName or the panel and node
|
||||
// namespaces diverge again. The whitespace collapse below is deliberately
|
||||
// ASCII-only ([\t\n\f\r ]) because Go's regexp \s class is ASCII-only — a
|
||||
// Unicode \s (U+00A0 etc.) would collapse to "-" here while Go removes it in
|
||||
// the [^\w\-_.] step, so the panel and node forms of the same name diverge.
|
||||
function sanitizeNodeStorageName(raw) {
|
||||
let name = String(raw || "").trim().replace(/[\t\n\f\r ]+/g, "-").replace(/[^\w\-_.]/g, "").replace(/^[-_.]+|[-_.]+$/g, "");
|
||||
while (name.length > 0 && !/^[A-Za-z0-9]/.test(name)) {
|
||||
name = name.slice(1);
|
||||
}
|
||||
if (name.length > 120) name = name.slice(0, 120);
|
||||
return name;
|
||||
}
|
||||
|
||||
function getCanonicalServerName(entry, fallback = "") {
|
||||
return sanitizeServerToken(entry?.name || fallback || "");
|
||||
}
|
||||
@@ -54,4 +88,6 @@ module.exports = {
|
||||
getTechnicalServerName,
|
||||
rewriteStartupCommandServerName,
|
||||
sanitizeServerToken,
|
||||
sanitizeDisplayNameToken,
|
||||
sanitizeNodeStorageName,
|
||||
};
|
||||
Reference in new issue
Block a user