getB2FileInfo throws IllegalArgumentException on a value with a stray percent sign

オープン 初心者向け
#246 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
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 を読んでください。130〜136行目付近の B2Headers.java の処理と比較してください。そこでは類似の失敗がすでに扱われています。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時間
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Backblaze/b2-sdk-java のほかの issue

Backblaze/b2-sdk-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。