✨ feat(api): 统一响应格式并完善参数体系与文档
- 正文参数支持语义值(plain/html/keep/remove)与别名(img_mode/review_mode),URL 参数优先于配置 - 修复纯文本被段评强制包回 HTML、HTML 模式段评注入失效的问题 - 修复 PKCS7 填充弱校验导致漫画/正文偶发解密乱码返回 200 的问题 - 搜索结果展平:去 search_tabs 层与 selected_tab_idx/server_ab_params,提升 has_more/next_offset - 全接口解包字符串形式的 JSON 字段(category_schema 等),缓存出口幂等处理 - 序列化关闭 HTML 转义,video/audio 播放链接可直接复制播放 - video 响应透传 CENC 加密状态(key_seed/kid/encryption_method) - 新增 gzip 中间件,JSON/文本响应压缩约 81%,二进制透传 - 漫画默认输出模式改为 proxy(url 模式链接 404 且内容加密不可用) - openapi.yaml:补全 23 个路径参数定义、tab_type 完整枚举、CDN 签名说明,示例更新
This commit is contained in:
1 parent
bfb4290c15
commit
1a4997e031
25 files changed
+489
-199
No files matched your search
+15
-5
@@ -234,8 +234,11 @@ func decryptAESContent(encrypted, secretKey string) (string, error) {
|
||||
plaintext := make([]byte, len(ciphertext))
|
||||
mode.CryptBlocks(plaintext, ciphertext)
|
||||
|
||||
// PKCS7 unpadding
|
||||
// PKCS7 unpadding(无效填充说明密钥不匹配,返回错误触发上层重试)
|
||||
plaintext = pkcs7Unpad(plaintext)
|
||||
if plaintext == nil {
|
||||
return "", fmt.Errorf("解密失败(无效填充,密钥可能不匹配)")
|
||||
}
|
||||
|
||||
// 尝试gzip解压
|
||||
if len(plaintext) > 2 && plaintext[0] == 0x1f && plaintext[1] == 0x8b {
|
||||
@@ -257,13 +260,20 @@ func decryptAESContent(encrypted, secretKey string) (string, error) {
|
||||
func pkcs7Unpad(data []byte) []byte {
|
||||
length := len(data)
|
||||
if length == 0 {
|
||||
return data
|
||||
return nil
|
||||
}
|
||||
unpadding := int(data[length-1])
|
||||
if unpadding > length {
|
||||
return data
|
||||
// 完整校验:值 1-16 且尾部 unpadding 个字节全等于填充值。
|
||||
// 密钥错误时解密结果是随机字节,弱校验会让乱码静默通过
|
||||
if unpadding < 1 || unpadding > 16 || unpadding > length {
|
||||
return nil
|
||||
}
|
||||
return data[:(length - unpadding)]
|
||||
for _, b := range data[length-unpadding:] {
|
||||
if int(b) != unpadding {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return data[:length-unpadding]
|
||||
}
|
||||
|
||||
// buildMangaResponse 构建漫画响应(统一HTML和JSON格式输出)
|
||||
|
||||
Reference in new issue
Block a user