// The dot-segment guard every direct mobile-api call applies (callMobileApi, and the routes that fetch bytes // themselves). Its own module so a test that mocks mobileApi still gets the real guard. Identical in both portals. /** Refuses dot-segment ("." / "..", also percent-encoded) and backslash paths, so a caller-supplied * value cannot traverse out of its intended upstream route (openspec/changes/block-member-admin-traversal). */ export function isTraversalPath(path: string): boolean { const p = path.split(/[?#]/, 1)[0]; if (p.includes("\\")) return true; let decoded: string; try { decoded = decodeURIComponent(p); } catch { return true; } if (decoded.includes("\\")) return true; return [...p.split("/"), ...decoded.split("/")].some(s => { const seg = s.split(";")[0]; // Tomcat strips ";params" before normalising, so "..;x" climbs like ".." return seg === "." || seg === ".."; }); }