getB2FileInfo throws IllegalArgumentException on a value with a stray percent sign

未关闭 适合新手
#246 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
api

调研方向

从 core/src/main/java/com/backblaze/b2/client/contentSources/B2Headers.java 中的 getB2FileInfo(约第 216 行,该值在此传给 URLDecoder)开始,然后阅读 core/src/main/java/com/backblaze/b2/util/B2StringUtil.java 中的 percentDecode。与 B2Headers.java 中第 130-136 行附近的处理方式进行比较,那里已经处理了类似的失败情况。当 100% 这样的值不再抛出 IllegalArgumentException 并保留原始值时即完成。通过一个测试进行验证:该测试使用 X-Bz-Info-note: 100% 构建 B2HeadersImpl 并调用 getB2FileInfo()。

由索引模型根据 Issue 内容生成。

描述

What happens

getB2FileInfo() percent-decodes each file info value with URLDecoder, which throws IllegalArgumentException for a malformed sequence such as 100%. Building a file version from download headers calls it, so the whole download fails for a file whose info value was stored raw by another client. getFileNameOrNull() in the same interface catches the same exception and returns null.

Where

core/src/main/java/com/backblaze/b2/client/contentSources/B2Headers.java:210-219 (getB2FileInfo, decode at :216), core/src/main/java/com/backblaze/b2/util/B2StringUtil.java:46-52 (percentDecode), called from core/src/main/java/com/backblaze/b2/client/B2StorageClientWebifierImpl.java:618. Compare B2Headers.java:130-136.

Why it matters

Impact: Availability (a download or metadata read fails), loud. Severity: High, because it needs a file info value stored with an unencoded percent sign by a client other than this SDK (unusual), and there is no workaround for that file besides a different client.

How to check

Found by reading the code, not reproduced. Read getB2FileInfo and percentDecode. A test could build B2HeadersImpl with X-Bz-Info-note: 100% and call getB2FileInfo(). Catching IllegalArgumentException and keeping the raw value would avoid the failure.

Version

Seen at v6.5.0. Present on the default branch: present.

主要语言
Java
星标
103
派生
23
平均合并
5 天 8 小时
30 天内合并 PR
3

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Backblaze/b2-sdk-java 的其他 Issue

查看 Backblaze/b2-sdk-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。