Skip to content

Merge remote changes - #71

Merged
sakitibi merged 1 commit into
mainfrom
dev
Jun 28, 2026
Merged

Merge remote changes#71
sakitibi merged 1 commit into
mainfrom
dev

Conversation

@sakitibi

@sakitibi sakitibi commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • ファイル内容のデコード方法を調整し、アップロード処理の互換性と安定性を向上しました。
    • 既存の送信・応答フローはそのまま維持されています。

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
asakura-wiki Ready Ready Preview, Comment Jun 28, 2026 2:25pm

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

pages/api/unzip/filenow_up.tsのPOSTハンドラにおいて、body.fileContentのBase64デコード処理をUint8Array.fromBase64(...)からBuffer.from(..., "base64")に1行変更。他の処理フローは変更なし。

Changes

Base64デコード修正

Layer / File(s) Summary
Base64デコード実装の変更
pages/api/unzip/filenow_up.ts
Uint8Array.fromBase64(body.fileContent)Buffer.from(body.fileContent, "base64")に置き換え。デコード後のデータをBlobにラップしてアップロードする流れは変わらない。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • sakitibi/AsakuraWiki#70: 同じpages/api/unzip/filenow_up.tsのPOSTハンドラでbody.fileContentのBase64デコードとBlobへの変換処理を修正している。
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive タイトルが一般的すぎて、base64デコード方法の変更という主な内容を示していません。 変更内容を要約する具体的なタイトルにしてください(例: unzip APIのbase64デコードをBufferに変更)。
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pages/api/unzip/filenow_up.ts`:
- Line 21: Handle invalid Base64 input in the unzip API before creating
decodedb64: the current Buffer.from(body.fileContent, "base64") path can accept
malformed data silently, so add explicit validation in the request handling flow
for body.fileContent and return a 400 response when it is not valid Base64. Keep
the check near the existing decodedb64 creation in the API route so the invalid
payload is rejected before any upload logic runs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e88d204-b435-4a58-8ada-ec2991b1158d

📥 Commits

Reviewing files that changed from the base of the PR and between 1895720 and 7675d95.

📒 Files selected for processing (1)
  • pages/api/unzip/filenow_up.ts

} else if (req.method === "POST") {
const body = req.body as FilePayload;
const decodedb64 = Uint8Array.fromBase64(body.fileContent);
const decodedb64 = Buffer.from(body.fileContent, "base64");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Node.js の Buffer.from(str, "base64")は不正な Base64 入力で例外を投げますか?Uint8Array.fromBase64() と比べた厳格さの違いも確認してください。

💡 Result:

Node.js の Buffer.from(str, 'base64') は、不正な Base64 入力に対して例外を投げません [1]。不正な文字や不完全なデータが含まれている場合でも、標準的な動作としてそれらを無視するか、あるいは適切に処理しようと試みるため、エラーにはならずに出力されます [1][2][3]。 一方、Uint8Array.fromBase64 は、より厳格な検証を行います [4][5]。このメソッドは、入力文字列に Base64 アルファベット以外の文字が含まれている場合や、指定された lastChunkHandling オプション(デフォルトは 'loose')を満たさない場合に SyntaxError を投げます [4][6]。 主な違いのまとめ: ・Buffer.from(str, 'base64'): ・寛容な(Forgiving)実装です。 ・不正な文字や空白は無視されます [2][7]。 ・例外を投げず、デコード結果を返します [1]。 ・Uint8Array.fromBase64: ・厳格な(Strict)実装です [8]。 ・Base64 アルファベット以外の文字が入力に含まれると SyntaxError になります [4][5]。 ・lastChunkHandling オプションにより、厳格さのレベルを調整できます('loose', 'strict', 'stop-before-partial')[6][9]。 このように、Node.js のレガシーな Buffer API と比較して、新しく導入された Uint8Array.fromBase64 は標準仕様に基づいて厳密なバリデーションを行うよう設計されています [10][8]。

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Compare the current decoder behavior against malformed inputs in a read-only probe.
node - <<'JS'
const samples = [
  'Zm9v',          // valid
  'Zm9v\n',        // valid with whitespace
  'Zm9v$',         // invalid char
  'Zg',            // missing padding
  '!!!!',          // invalid
  'Zm=9v',         // misplaced padding
];

for (const s of samples) {
  try {
    const b = Buffer.from(s, 'base64');
    console.log(JSON.stringify({ input: s, ok: true, len: b.length, hex: b.toString('hex') }));
  } catch (e) {
    console.log(JSON.stringify({ input: s, ok: false, name: e.name, message: e.message }));
  }
}
JS

Repository: sakitibi/AsakuraWiki

Length of output: 446


不正な Base64 は 400 で弾いてください。
Buffer.from(body.fileContent, "base64") は不正文字や不完全な入力でも例外にならず、空/破損したバイト列をそのまま外部アップロードに流します。Line 21 で明示的な検証とエラー応答を残すべきです。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pages/api/unzip/filenow_up.ts` at line 21, Handle invalid Base64 input in the
unzip API before creating decodedb64: the current Buffer.from(body.fileContent,
"base64") path can accept malformed data silently, so add explicit validation in
the request handling flow for body.fileContent and return a 400 response when it
is not valid Base64. Keep the check near the existing decodedb64 creation in the
API route so the invalid payload is rejected before any upload logic runs.

@sakitibi
sakitibi merged commit f7063e7 into main Jun 28, 2026
3 checks passed
@sakitibi
sakitibi deleted the dev branch June 28, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant