928fc1a0de
Merge branch 'improve-tests-and-comments'
...
完善单元测试与代码注释。测试 254 → 290(净增 36 个有价值测试),
顺带修复 highlight.rs 中大写语言标识无法走别名映射的 bug。
- theme.rs: 2 → 8(主题切换对合性、预加载脚本契约)
- highlight.rs: 7 → 15(别名映射、大小写回退,修复 'RUST' 回退纯文本 bug)
- webp.rs: 6 → 16(编解码错误处理、像素格式转换路径、Display 格式)
- sanitizer.rs: 8 → 17(is_safe_url 安全敏感分支直接测试)
- error.rs: 5 → 8(AppError 各变体消息转换)
2026-06-15 11:27:33 +08:00
19ffcada4a
test: 移除脆弱断言与凑数测试(review 修正)
...
对本次新增测试自审后的清理:
1. webp: encode_lower_quality_produces_smaller_or_equal_bytes
原断言“低质量体积 <= 高质量体积”是 WebP 的统计趋势而非
确定性不变量,依赖底层 libwebp 量化策略,纯色图上高低差异
接近 0,未来库升级易变为 flaky。改为验证两个质量档位都能
成功编码并产生可被本模块解码的合法 WebP。
2. theme: theme_is_copy
Copy 语义由编译器在编译期保证,运行期断言永真,不测任何
运行逻辑,属凑数。
3. webp: webp_config_default_quality_and_method
构造 struct 再断言字段等于构造时填入的值,是同义反复。
净减 2 个测试(292 → 290),全部通过。
2026-06-15 11:26:24 +08:00
263208b930
style: 修正新测试的格式以符合 rustfmt 宽度限制
...
cargo fmt 自动调整了 highlight.rs 与 error.rs 中新增测试的
assert! / assert_eq! 长行折行。
2026-06-15 11:22:35 +08:00
9fc626232c
test(error): 补全 AppError 各变体的消息转换测试
...
原仅覆盖 Unauthorized/Forbidden/NotFound/DbConn/Query 五个变体,
补充:
- Internal 变体的消息透传
- Transaction 变体的 SQL 细节隐藏(与 Query 行为一致)
- 三类数据库错误统一返回中文通用提示的聚合断言
共 8 个测试,全部通过。
2026-06-15 11:20:33 +08:00
28f0117f06
test(sanitizer): 补充 is_safe_url 分支测试
...
is_safe_url 是 HTML 消毒器的安全核心,原仅通过 clean_html 间接覆盖。
新增 9 个直接单元测试,锁定各分支契约:
- https/http 白名单通过
- javascript / vbscript scheme 拒绝(含大小写混淆)
- data URI 按 allow_data_uri 标志决定(文章正文 vs 评论)
- 相对路径与锚点片段通过
- 空字符串/纯空白视为安全
- mailto / tel / ftp 等其它白名单 scheme 通过
- 含空白的 scheme 名(混淆手法)被拒绝
共 17 个测试,全部通过。
2026-06-15 11:19:46 +08:00
a9cde41de8
test(webp): 扩充 WebP 编解码测试覆盖
...
原仅 6 个测试,补充后覆盖:
- WebpError 的 Display 格式与 std::error::Error trait 约束
- encode 对非快速路径像素格式(Luma8 / LumaA8)的 RGBA 转换
- encode 质量参数对体积的单调性(低质量 <= 高质量)
- decode 对非法字节流与空输入的错误处理(不 panic)
- decode 错误信息带 'WebP decode error' 前缀便于排查
- 编解码往返保持图像尺寸不变
共 17 个测试,全部通过。
2026-06-15 11:18:55 +08:00
e9aac7d6b4
fix(highlight): 修复大写语言标识无法走别名映射的问题
...
别名表此前用 lang == from 做严格相等比较,导致 'RUST' 这类
大写标识无法命中 ('rust' → 'rs') 这类别名,最终回退到纯文本。
改用 eq_ignore_ascii_case 比较,使别名解析与扩展名/名称的小写
回退路径保持一致。
test(highlight): 补充 find_syntax 分支覆盖
新增 8 个测试覆盖此前未测的路径:
- 大写语言标识的小写回退(同时验证了上述修复)
- 别名表:golang/bash/yml 等映射
- 未知语言与空字符串的纯文本回退
- 代码首尾空白被 trim
- 多行代码逐行高亮
通过等价性断言(而非脆弱的 span class 字面量)校验别名解析,
避免 syntect 内部 class 命名变化导致测试漂移。
共 15 个测试,全部通过。
2026-06-15 11:17:53 +08:00
4e89412cde
test(theme): 扩充主题模块测试覆盖
...
原仅 2 个 toggle 测试,补充后覆盖:
- toggle 的对合性(连续切换两次回到原值)
- Theme 的 PartialEq / Copy trait 行为
- 首屏预加载脚本的关键行为契约:读取 localStorage、
回退 prefers-color-scheme、添加 dark class、
包裹 try/catch 防止禁用 localStorage 时抛错
共 9 个测试,全部通过。
2026-06-15 10:57:51 +08:00
81ee60a77d
chore: ignore .worktrees directory
...
Add .worktrees/ to .gitignore so isolated git worktrees created for
parallel development work are not accidentally tracked.
2026-06-15 10:50:48 +08:00
e12e59461b
docs: 整理表格格式并添加 CI 链接
CI / check (push) Successful in 12m26s
CI / build (push) Failing after 13m0s
2026-06-15 10:41:03 +08:00
f7288cc390
style: 格式化测试代码以符合 clippy 宽度限制
2026-06-15 10:40:00 +08:00
0242534274
style(tags): 修复文档注释列表缩进以消除 clippy 警告
CI / check (push) Failing after 4m52s
CI / build (push) Has been skipped
2026-06-12 19:48:10 +08:00
194611bb7e
docs(bin): 补充中文注释
2026-06-12 19:45:59 +08:00
c43da3676f
docs(components): 补充中文注释
2026-06-12 19:42:42 +08:00
c5d1eb117c
docs(auth-pages, router, main): 补充中文注释
2026-06-12 19:31:21 +08:00
18500c9496
docs(pages-admin): 补充中文注释
2026-06-12 19:24:22 +08:00
abfab19839
docs(pages-frontend): 补充中文注释
2026-06-12 19:16:59 +08:00
1904907add
docs(hooks, theme): 补充中文注释
2026-06-12 19:07:43 +08:00
671a9fea7a
docs(infra): 补充中文注释
2026-06-12 19:02:37 +08:00
2db652137d
docs(models, db, cache): 补充中文注释
2026-06-12 18:56:56 +08:00
a785683fc6
docs(posts): 补充中文注释
2026-06-12 18:50:17 +08:00
9921f8eebf
docs(comments): 补充中文注释
2026-06-12 18:42:19 +08:00
26b012c40c
docs(api, auth): 补充中文注释
2026-06-12 18:27:24 +08:00
4fe26f7eb3
test: improve unit test coverage and assertions
...
CI / check (push) Failing after 15m51s
CI / build (push) Has been skipped
- Add tests for sanitizer, mime_to_ext, clean_tags, Theme::toggle
- Tighten assertions in highlight, markdown, post status classes
- Add boundary and XSS cases for comments, slug, rate_limit, webp
- Update Cargo.lock for serial_test dev-dependency
2026-06-12 18:13:51 +08:00
6fe7dc3ff5
build: use npx tailwindcss instead of global binary
CI / check (push) Successful in 8m46s
CI / build (push) Has been cancelled
2026-06-12 18:09:20 +08:00
220a1f91b0
ci: retry rustup install on network failure
CI / check (push) Successful in 7m51s
CI / build (push) Failing after 8m18s
2026-06-12 17:44:19 +08:00
041cdf4102
test(cache): mark cache tests serial to fix parallel flakiness
2026-06-12 17:40:15 +08:00
fa6fa9a77c
docs: document COOKIE_SECURE and TRUSTED_PROXY_COUNT
2026-06-12 17:31:20 +08:00
997f9b4617
ci: switch to rsproxy cargo mirror
CI / check (push) Successful in 10m25s
CI / build (push) Failing after 2m45s
2026-06-12 17:29:37 +08:00
942ac853fe
refactor: tighten module-level allow attributes
2026-06-12 17:26:46 +08:00
294d60afab
style: format rust code
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
2026-06-12 17:14:31 +08:00
71ac08c373
feat(rate_limit): derive real client IP from X-Forwarded-For with TRUSTED_PROXY_COUNT
2026-06-12 17:13:17 +08:00
c8182f89da
ci: back to runner host with tsinghua rustup mirror
CI / check (push) Failing after 8m4s
CI / build (push) Has been skipped
2026-06-12 17:05:13 +08:00
cb137cfdfb
ci: use printf instead of heredoc for cargo config
CI / check (push) Failing after 0s
CI / build (push) Has been skipped
2026-06-12 17:04:17 +08:00
8014e202f8
ci: use aliyun rust mirror container
CI / check (push) Failing after 1s
CI / build (push) Has been skipped
2026-06-12 17:03:38 +08:00
4ae7b38131
feat(auth): add Secure flag to session cookie via COOKIE_SECURE env
2026-06-12 17:02:22 +08:00
a070e3f8fc
ci: use tsinghua rustup mirror and ustc cargo mirror
CI / check (push) Failing after 6s
CI / build (push) Has been skipped
2026-06-12 16:57:07 +08:00
cab12a1e5e
ci: replace actions/checkout with raw git clone
CI / check (push) Failing after 3m33s
CI / build (push) Has been skipped
2026-06-12 16:42:17 +08:00
99e1f2e98d
ci: avoid actions/setup-node, install node via nodesource
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
2026-06-12 16:41:38 +08:00
94de78c513
ci: run directly on runner without docker container
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
2026-06-12 16:39:12 +08:00
2a19bc4e28
ci: add gitea actions workflow
CI / check (push) Failing after 55s
CI / build (push) Has been skipped
2026-06-12 16:31:19 +08:00
b72bc512c2
chore(make): use npm ci for tiptap editor to avoid lockfile drift
2026-06-12 16:27:12 +08:00
ee6aaf179c
feat(posts): add batch limit and error handling to rebuild_content_html
2026-06-12 11:44:53 +08:00
835d71972c
fix(admin): add missing dark mode background colors to skeleton components
2026-06-12 11:15:46 +08:00
a10bf8737c
refactor(sanitizer): extract shared sanitizer module and migrate from ammonia to lol_html
2026-06-12 11:15:42 +08:00
b898b55308
chore: add profile.json.gz to .gitignore
2026-06-12 10:56:56 +08:00
f8fb35f8c2
fix(admin): use arbitrary value for tooltip dark text color
2026-06-12 10:55:32 +08:00
1c3f1aac34
fix(admin): flip tooltip to bottom to avoid navbar overlap
...
Changed from bottom-full/mb-2 to top-full/mt-2, added z-50.
2026-06-12 10:54:02 +08:00
8840faa830
fix(admin): use arbitrary dark mode values for tooltip bg
...
Matches project pattern of dark:text-[#dadadb] / dark:bg-[#dadadb]
for reliable Tailwind v4 class-based dark mode.
2026-06-12 10:52:05 +08:00
c62cf5a239
feat(admin): add tooltip to rebuild content button
...
Pure CSS tooltip appears on hover, inverted color scheme
(white-on-dark / dark-on-light) matching admin aesthetic.
2026-06-12 10:50:18 +08:00