Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Base64 decoder: detect AVIF, SVGs with a prolog, real BMPs and long JSON

クローズ
#205 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nextjs, typescript
領域
tooling

調査の方向性

Start with getMimeFromMagicBytes in lib/base64-utils.ts and the “magic bytes” tests in lib/__tests__/base64-utils.test.ts; the issue identifies the BMP, ftyp, XML/HTML, JSON, and SVG checks to inspect. Add byte-built tests for each listed case, then run npm run lint, npm run test, and npm run build. Done means all acceptance criteria pass, including preserving other ftyp brand detection.

索引モデルが issue の本文から書いたものです。

説明

bug good first issue hacktoberfest

The Base64 tool's decoder guesses the type of the decoded bytes with getMimeFromMagicBytes (lib/base64-utils.ts, line 103). The guess sets the "Detected type", MIME and extension, the name of the downloaded file, and whether an image preview is shown. Five cases come out wrong:

Decoded bytes Detected now Should be
An AVIF image (ftyp box with the brand avif or avis) MP4 video AVIF image, image/avif, with a preview
An SVG that starts with <?xml ...?> XML document SVG image
An SVG with a <!DOCTYPE svg ...> HTML document SVG image
Text that starts with "BM", like "BMW is a car maker" BMP image, with a broken preview Plain text
JSON longer than 4096 bytes Plain text JSON document

The "BM" one happens because the BMP check only looks at two bytes (line 112). The JSON one because only the first 4096 bytes are parsed (line 151), so a longer document never parses.

Where to look

  • lib/base64-utils.ts, getMimeFromMagicBytes: BMP at line 112, the ftyp brands at lines 124 to 129, XML and HTML at lines 145 to 148, JSON at lines 149 to 156, SVG at lines 157 and 158
  • app/(tools)/base64/components/DecodeTab.tsx (lines 36 to 50 and 143 to 152) shows how the result is used
  • lib/__tests__/base64-utils.test.ts: the "magic bytes" block at line 266

Acceptance criteria

  • AVIF (brands avif and avis) is detected as image/avif with isImage: true, and other ftyp brands work as before
  • SVG is detected when <svg comes after an XML declaration, a doctype, comments or whitespace at the start
  • "BM" only counts as BMP when the header looks like a real bitmap, for example when the header size at bytes 14 to 17 is one of the known sizes (12, 16, 40, 52, 56, 64, 108 or 124)
  • JSON longer than 4096 bytes is detected as JSON, with a size cap so huge inputs stay fast (for example 1 MB)
  • Tests in lib/__tests__/base64-utils.test.ts for each case above, with the bytes built in the test
  • npm run lint, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #205 in the description.

主要言語
TypeScript
スター
1
フォーク
9
平均マージ
9時間 9分
マージ済み PR(30日)
118

環境構築

はじめの一歩

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

codercops/toolbelt のほかの issue

codercops/toolbelt の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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