Base64 decoder: detect AVIF, SVGs with a prolog, real BMPs and long JSON
メンテナーはふだん 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 の本文から書いたものです。
説明
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, theftypbrands at lines 124 to 129, XML and HTML at lines 145 to 148, JSON at lines 149 to 156, SVG at lines 157 and 158app/(tools)/base64/components/DecodeTab.tsx(lines 36 to 50 and 143 to 152) shows how the result is usedlib/__tests__/base64-utils.test.ts: the "magic bytes" block at line 266
Acceptance criteria
- AVIF (brands
avifandavis) is detected asimage/avifwithisImage: true, and otherftypbrands work as before - SVG is detected when
<svgcomes 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.tsfor each case above, with the bytes built in the test -
npm run lint,npm run testandnpm run buildpass
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codercops/toolbelt のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
JWT encoder signs payloads that aren't JSON objects, and the decoder then rejects them対応中かも @MugdhoAI が 1 日前に担当しました。 オープンbug good first issue hacktoberfest
codercops/toolbelt#253 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
JSON to YAML: control characters are written raw, so PyYAML and js-yaml can't read the output対応中かも @anurag2787 が 1 日前に担当しました。 オープンbug good first issue hacktoberfest
codercops/toolbelt#234 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
JSON formatter: Escape for code gives broken Python when the text has a run of single quotes対応中かも @anurag2787 が 1 日前に担当しました。 オープンbug good first issue hacktoberfest
codercops/toolbelt#233 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Add the URL encoder to the README, the home share card and package.json対応中かも @Abhishek764 が 4 日前に担当しました。 オープンdocumentation good first issue hacktoberfest
codercops/toolbelt#153 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
codercops/toolbelt の issue をすべて見る
似ている issue
-
bug skills
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
equinor/fusion-framework#5846 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Eyevinn/open-videocore#1256 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Theme preset geist points at undefined --font-geist対応中かも @claude が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信