Subir archivos a "integra-mcp"
This commit is contained in:
@@ -21,7 +21,29 @@ export function normalizeOrigin(value) {
|
||||
|
||||
export function safeRedirect(value) {
|
||||
try {
|
||||
if (typeof value !== 'string') return false;
|
||||
const u = new URL(value);
|
||||
return !u.username && !u.password && !u.hash && u.protocol === 'https:';
|
||||
return !u.username && !u.password && !u.hash && (u.protocol === 'https:' || isLoopbackRedirect(value));
|
||||
} catch { return false; }
|
||||
}
|
||||
|
||||
export function isLoopbackRedirect(value) {
|
||||
try {
|
||||
if (typeof value !== 'string' || !/^http:\/\/127\.0\.0\.1(?::[0-9]+)?(?:\/|$)/.test(value)) return false;
|
||||
const u = new URL(value);
|
||||
return u.protocol === 'http:' && u.hostname === '127.0.0.1' && !u.username && !u.password && !u.hash;
|
||||
} catch { return false; }
|
||||
}
|
||||
|
||||
export function redirectAllowed(requested, registeredUris) {
|
||||
if (!safeRedirect(requested)) return false;
|
||||
return registeredUris.some(registered => {
|
||||
if (!safeRedirect(registered)) return false;
|
||||
if (requested === registered) return true;
|
||||
if (!isLoopbackRedirect(requested) || !isLoopbackRedirect(registered)) return false;
|
||||
const a = new URL(requested), b = new URL(registered);
|
||||
// RFC 8252: a native client chooses a free local port at login. Only that
|
||||
// port may vary; the registered host, path and query must still match.
|
||||
return a.pathname === b.pathname && a.search === b.search;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user