ff2694c5a3
feat(image): make size/pixel limits configurable, double defaults
...
CI / check (push) Failing after 6m23s
CI / build (push) Has been skipped
将 MAX_IMAGE_DIMENSION / MAX_IMAGE_PIXELS 从编译期 const 改为运行时
LazyLock(启动读环境变量),默认值 x2。
- 默认值:单边 4096→8192,总像素 25M→50M
- clamp 策略:只设下限防危险小值(DIMENSION≥512,PIXELS≥1M),
超下限 clamp + warn;无上限,完全信任运维
- 内存影响:默认 50M 像素对应 ~200MB/图解码缓冲(max_alloc)
- 模式复用 WEBP_CONFIG:env→parse→(val,clamped)→clamp→warn→info
- 所有引用点解引用(*MAX_...),含 upload.rs/webp.rs 跨文件
- check_upload_dimensions 超限文案改为动态读取上限,不再硬编码数值
- 测试改用 *MAX_IMAGE_DIMENSION+1,数值无关
.env.example 与 AGENTS.md 同步更新环境变量说明。
2026-06-24 13:54:36 +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
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
671a9fea7a
docs(infra): 补充中文注释
2026-06-12 19:02:37 +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
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
b7220c28ef
Fix WebpError trait impls missing #[cfg(feature = "server")]
2026-06-09 18:30:10 +08:00
c08d35856e
test: add WebP config parsing and clamping tests
2026-06-09 16:04:26 +08:00
05cf2f79ea
refactor: extract WebP encode helper to reduce duplication
2026-06-09 15:59:02 +08:00
035d11e39b
fix: log warning when WebP env vars are clamped
2026-06-09 15:53:39 +08:00
db3379364f
fix: limit WebP decode buffer size to prevent malicious allocations
2026-06-09 15:48:34 +08:00
2e2be7b16d
feat: add WebP encoding support with zenwebp
...
- Replace image crate's WebP with zenwebp for better quality/speed
- Add webp.rs module with configurable quality and method
- Update .env.example with WEBP_QUALITY and WEBP_METHOD
- Add WebP decode support in image serving pipeline
- Add detailed timing logs for WebP conversion
2026-06-09 15:30:06 +08:00