Skip to content

blob: unaligned UTF-16LE decode for odd-length/odd-address views#31006

Closed
alii wants to merge 13 commits into
mainfrom
ali/blob-utf16-odd-length
Closed

blob: unaligned UTF-16LE decode for odd-length/odd-address views#31006
alii wants to merge 13 commits into
mainfrom
ali/blob-utf16-odd-length

blob: drop trailing odd byte in UTF-16LE decode instead of aborting

106e7d8
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 18, 2026 in 13m 14s

Code review found 1 important issue

Found 6 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/runtime/webcore/Blob.rs:2671-2674 bytemuck::cast_slice still panics on misaligned buf from sliced Blobs
🟡 Nit test/js/web/fetch/blob.test.ts:346-350 Test pipes stderr but never reads or asserts on it

Annotations

Check failure on line 2674 in src/runtime/webcore/Blob.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

bytemuck::cast_slice still panics on misaligned buf from sliced Blobs

`bytemuck::cast_slice::<u8, u16>` panics on two conditions — odd *length* and odd *alignment* — and this PR only fixes the first. `shared_view_raw()` returns `base + self.offset`, so e.g. `new Blob([Buffer.concat([Buffer.from([0x00, 0xFF, 0xFE]), Buffer.from('hi', 'utf16le')])]).slice(1).text()` hands an odd-address `buf` to `cast_slice`, which still aborts the process with `PodCastError::TargetAlignmentGreaterAndInputNotAligned` (the deleted comment even said "bytemuck checks align + even-len")

Check warning on line 350 in test/js/web/fetch/blob.test.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Test pipes stderr but never reads or asserts on it

nit: `stderr: "pipe"` is set but `proc.stderr` is never read. Consider adding `proc.stderr.text()` to the `Promise.all` and asserting `expect(stderr).toBe("")` first (matching the neighboring `dupeWithContentType` test and the pattern in test/CLAUDE.md) so the panic message isn't swallowed if this ever regresses.