Skip to content

Comments

fix(node/buffer): fix latin1Slice and hexSlice returning wrong results#32277

Open
bartlomieju wants to merge 1 commit intodenoland:mainfrom
bartlomieju:fix/buffer-latin1-hex-slice
Open

fix(node/buffer): fix latin1Slice and hexSlice returning wrong results#32277
bartlomieju wants to merge 1 commit intodenoland:mainfrom
bartlomieju:fix/buffer-latin1-hex-slice

Conversation

@bartlomieju
Copy link
Member

Summary

  • Fix Buffer.prototype.latin1Slice and Buffer.prototype.hexSlice having an extraneous string parameter that shifted all arguments passed to the underlying _latin1Slice/_hexSlice functions
  • Fix _latin1Slice not handling missing start/end arguments, causing it to return empty strings when called with no arguments
  • Add unit tests for both methods

Fixes #32276

Test plan

  • cargo test unit_node::buffer_test passes
  • Manually verified Buffer.of(1,2,3,0xff).latin1Slice() returns a 4-character string (previously returned empty string)
  • Manually verified hexSlice() and hexSlice(start, end) return correct results

🤖 Generated with Claude Code

Both `latin1Slice` and `hexSlice` had an extraneous `string` parameter
that shifted all arguments, causing the underlying slice functions to
receive wrong values. Additionally, `_latin1Slice` didn't handle missing
`start`/`end` arguments, resulting in empty strings when called with no
arguments.

Fixes denoland#32276

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Buffer#latin1Slice() returns empty strings

1 participant