2aa9d73325
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
26 lines
644 B
JavaScript
26 lines
644 B
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { isSafePostLoginRedirect } from './data.js';
|
|
|
|
test('isSafePostLoginRedirect only allows same-origin relative paths', () => {
|
|
for (const ok of [
|
|
'/console',
|
|
'/client/authorize?client_id=weyai-desktop&state=a%5Cb',
|
|
]) {
|
|
assert.equal(isSafePostLoginRedirect(ok), true, ok);
|
|
}
|
|
for (const bad of [
|
|
'',
|
|
'https://evil.example.com',
|
|
'//evil.example.com',
|
|
'/\\evil.example.com',
|
|
'/\\/evil.example.com',
|
|
'/console\\..\\x',
|
|
'/login',
|
|
'/org/login',
|
|
]) {
|
|
assert.equal(isSafePostLoginRedirect(bad), false, bad);
|
|
}
|
|
});
|