Skip to content

Buffer.from(..., 'hex') does not truncate at first non-hexadecimal value #31083

@davidebombelli

Description

@davidebombelli

Summary

When using Buffer.from() with hexadecimal, the data should be truncated when the first non-hexadecimal value is encountered, as it does in Node.js.

Version

deno 2.5.4 (stable, release, x86_64-unknown-linux-gnu)

v8 14.0.365.5-rusty

typescript 5.9.2

OS

Linux Mint 22 Wilma

Steps to reproduce

  1. Create file test.mjs with the following content:
import { Buffer } from 'node:buffer';

console.log(Buffer.from('1ag123', 'hex'));
  1. Run file deno test.mjs.

Expected Behaviour

<Buffer 1a>

Actual Behaviour

<Buffer 1a 01 23>

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions