fish2018/pansou · warning
Base64解码失败
Error message
Base64解码失败: %w
What it means
DecryptURL failed to Base64-decode the item.URL value using base64.StdEncoding. The sdso API is expected to return standard-Base64-encoded AES ciphertext; anything else (raw URLs, URL-safe Base64, whitespace, HTML fragments) fails decoding. The plugin skips such items.
Solutions
- Internal handling: the plugin skips the failing item — no caller action required.
- If nearly all items fail, the site likely changed encoding: try base64.RawStdEncoding or base64.URLEncoding in DecryptURL.
- Dump a sample item.URL (DebugLog) and verify its encoding manually.
- Check whether sdso.top now returns plaintext links, making decryption obsolete.
Example fix
// before
ciphertext, err := base64.StdEncoding.DecodeString(encryptedURL)
// after
ciphertext, err := base64.StdEncoding.DecodeString(encryptedURL)
if err != nil {
ciphertext, err = base64.URLEncoding.DecodeString(encryptedURL)
}
if err != nil {
return "", fmt.Errorf("Base64解码失败: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
// quick Base64 sanity check before decrypting
if _, err := base64.StdEncoding.DecodeString(item.URL); err != nil { /* skip: not standard Base64 */ } Try / catch
decryptedURL, err := DecryptURL(item.URL)
if err != nil {
log.Printf("skipping item (decode failed): %v", err)
return nil // or continue to next item
} Prevention
- Trim whitespace/HTML escaping from the URL value first
- Fall back to URLEncoding/RawStdEncoding if the site changes schemes
- Sample and inspect item.URL values when failures spike
When it happens
Trigger: item.URL contains characters outside the standard Base64 alphabet or wrong padding, e.g. the API returned a plaintext link, URL-safe Base64 (-/ instead of +/), a padded-with-whitespace value, or an HTML-escaped string.
Common situations: The site changing its encryption/encoding scheme (e.g. switching to URL-safe Base64 or raw URLs) after a frontend update; individual corrupted records in the search index; HTML escaping of + and / characters.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/2cbcde2c7f86ffd8.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/sdso/sdso.go:386
}
lastErr = err
}
return nil, fmt.Errorf("重试 %d 次后仍然失败: %w", maxRetries, lastErr)
}
// DecryptURL 解密SDSO网站返回的加密URL
// 输入: Base64编码的密文
// 输出: 解密后的原始网盘链接
func DecryptURL(encryptedURL string) (string, error) {
if encryptedURL == "" {
return "", fmt.Errorf("加密URL不能为空")
}
// Base64解码
ciphertext, err := base64.StdEncoding.DecodeString(encryptedURL)
if err != nil {
return "", fmt.Errorf("Base64解码失败: %w", err)
}
// 检查密文长度
if len(ciphertext) == 0 {
return "", fmt.Errorf("密文长度为0")
}
// 检查密文长度是否为16的倍数
if len(ciphertext)%aes.BlockSize != 0 {
return "", fmt.Errorf("密文长度不是AES块大小的倍数")
}
// 创建AES块加密器
block, err := aes.NewCipher([]byte(AESKey))
if err != nil {
return "", fmt.Errorf("创建AES加密器失败: %w", err)
}
View on GitHub (pinned to beaa561337)