getB2FileInfo throws IllegalArgumentException on a value with a stray percent sign

Open Beginner friendly
#246 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
api

Research direction

Start in core/src/main/java/com/backblaze/b2/client/contentSources/B2Headers.java at getB2FileInfo (around line 216, where the value is passed to URLDecoder), then read percentDecode in core/src/main/java/com/backblaze/b2/util/B2StringUtil.java. Compare with the handling in B2Headers.java around lines 130-136, which already deals with a similar failure. Done when a value such as 100% no longer throws IllegalArgumentException and the raw value is kept, verified by a test that builds B2HeadersImpl with X-Bz-Info-note: 100% and calls getB2FileInfo().

Written by the indexing model from the issue text.

Description

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.

Dominant language
Java
Stars
103
Forks
23
Avg merge
5d 8h
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Backblaze/b2-sdk-java

All issues in Backblaze/b2-sdk-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.