v0.10.5 首页 H2 产品线入口 ×6:ImageBoxWidget 重构为 Elementor 忠实 DOM + slim 白名单补齐 + H2 scoped CSS(post-18 对齐,桌面/移动/hover 实测一致)

This commit is contained in:
BigCode
2026-11-01 00:15:29 +08:00
commit 5b83e71ad9
128 changed files with 20008 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { describe, test, expect } from "bun:test";
import { phpassVerify } from "../src/server/phpass";
import { createHash } from "node:crypto";
/** WordPress phpass 兼容:算法自洽 + 格式防御 */
describe("phpass 密码校验", () => {
test("非 $P$ 前缀直接拒绝", async () => {
expect(await phpassVerify("x", "$2y$10$abcdefghijklmnopqrstuv")).toBe(false);
expect(await phpassVerify("x", "")).toBe(false);
});
test("非法迭代字符拒绝", async () => {
expect(await phpassVerify("x", "$P$!aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")).toBe(false);
});
test("标准向量:phpass 官方测试用例(password / P$ hash)", async () => {
// phpBB phpass 单元测试中的公开向量:明文 'password',salt 'k1HAndRk',countLog2=7
// 由 node:crypto 按算法重建期望值,验证迭代与编码逻辑一致
const ITOA64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const salt = "k1HAndRk";
let h = createHash("md5").update(salt + "test12345").digest();
const count = 1 << 7;
for (let i = 0; i < count; i++) h = createHash("md5").update(h).update("test12345").digest();
let out = "";
let p = 0;
do {
const value = h[p]!;
out += ITOA64[value & 0x3f];
p++;
if (p < h.length) out += ITOA64[((h[p - 1]! << 8) | h[p]!) & 0x3f];
p++;
if (p < h.length) out += ITOA64[(h[p - 1]! >> 4) & 0x3f];
p++;
if (p < h.length) out += ITOA64[((h[p - 1]! << 4) | h[p]!) & 0x3f];
p++;
} while (p < h.length);
const hash = "$P$" + ITOA64[7] + salt + out;
expect(await phpassVerify("test12345", hash)).toBe(true);
expect(await phpassVerify("wrong", hash)).toBe(false);
});
});