Skip to content

Releases

v3.0.0

Choose a tag to compare

@keichi keichi released this 22 Nov 07:54

Breaking changes

  • ESM only. The CommonJS build has been removed and the package is now "type": "module". Use import { Parser } from "binary-parser". Node.js >= 22.12 can still require() it via require(esm). (#308)
  • Node.js 22.12 or later is required (was 14). Output now targets ES2022. (#303, #346)
  • Stricter validation. The following now throw instead of silently misbehaving:
    • __proto__ as an associative array key (#322, #328)
    • An array element that consumes no bytes in readUntil: "eof" or lengthInBytes arrays, which previously looped forever (#319)
    • string types in choice() and wrapped() when varName is omitted (#325)
    • Non-string or unsupported encoding values; encodings are validated with TextDecoder at compile time (#345)
  • Behavior changes:
    • binary, base64 and base64url strings are decoded the same way as Node.js Buffer (#324)
    • assert honors falsy values such as 0 and "" (#335)
    • Wrapper functions and deferred bit field formatters are called with the current context as this (#339, #343)

New features

  • skipBits() to skip bits without storing them (#331)
  • Length 0 is allowed for string, buffer, wrapped and array (#320)

Bug fixes

  • Greedy strings no longer leave the offset one past the end of the buffer (#315)
  • Strings with both length and zeroTerminated are parsed correctly (#318)
  • bitN() and string() no longer mutate the caller's options object (#317)
  • sizeOf() and parser compilation no longer overflow the stack on long chains (#333, #340)
  • Assertions on deferred bit fields inside nested parsers work (#341)
  • Buffer and Node.js built-ins are detected by feature instead of window (#304)
  • Fixed typos in choice error messages (#316)
  • Fixed the bundled examples (#309, #310, #311, #312, #313)

Other

  • Tests migrated to Vitest and run on Node.js, Bun, Deno and browsers (#302, #304, #307)
  • Switched to TypeScript 7, oxlint and oxfmt (#305, #337, #342, #344)
  • npm packages are published with provenance (#314)

Thanks to @Lezvix, @hippi345, @Aschenbath and @imsurya26 for contributing!

Full Changelog: v2.3.1...v3.0.0

v2.3.1

Choose a tag to compare

@keichi keichi released this 11 Nov 02:59

Security fix

Fixes a code injection vulnerability (GHSA-xmxc-6c22-m377) where string-typed options were interpolated verbatim into the generated parser code. Applications that build parser definitions from untrusted input should upgrade.

Affected options: length of string, buffer, array, wrapped and seek; lengthInBytes and key of array; tag of choice; offset of pointer; and the alias passed to namely().

Breaking change

These options now only accept identifier paths (e.g. "len", "$parent.len"). Expressions such as "len - 1" are rejected at compile time; use a function instead (e.g. function () { return this.len - 1; }).

Full Changelog: v2.3.0...v2.3.1

v2.3.0

Choose a tag to compare

@keichi keichi released this 26 Nov 05:44

What's Changed

  • Fix typos by @mohd-akram in #224
  • Don't assume nest contains a bit field by @nick-hunter in #241
  • Add CodeQL workflow for GitHub code scanning by @lgtm-com[bot] in #225
  • Bump node.js version requirement by @keichi in #242
  • Use DataView instead of Buffer in hand-written benchmark by @screeny05 in #249
  • Bugfix: Make pointer accept offset=0 by @DominicChm in #255
  • Update classfile.ts for better parser by @Kreijstal in #260
  • build(deps-dev): bump pbkdf2 from 3.1.2 to 3.1.3 by @dependabot[bot] in #275
  • build(deps): bump tmp from 0.2.1 to 0.2.4 by @dependabot[bot] in #276
  • Fix code injection vulnerability via field names and encoding names by @keichi in #283

New Contributors

Full Changelog: v2.2.1...v2.3.0

v2.2.1

Choose a tag to compare

@keichi keichi released this 20 Sep 07:32
v2.2.1

What's Changed

  • docs: explain how to call .useContextVars() by @wpyoga in #220
  • Fix source map by uploading entire dist folder with map files and lib folder with source by @cmdcolin in #218
  • Update dependencies by @keichi in #222

New Contributors

Full Changelog: v2.2.0...v2.2.1

v2.2.0

Choose a tag to compare

@keichi keichi released this 05 Sep 10:17
v2.2.0

What's Changed

New Contributors

Full Changelog: v2.1.0...v2.2.0

v2.1.0

Choose a tag to compare

@keichi keichi released this 05 Jun 14:43
v2.1.0

What's Changed

Full Changelog: v2.0.3...v2.1.0

v2.0.3

Choose a tag to compare

@keichi keichi released this 09 May 11:28
v2.0.3

What's Changed

New Contributors

Full Changelog: v2.0.2...v2.0.3

v2.0.2

Choose a tag to compare

@keichi keichi released this 24 Nov 12:39
v2.0.2

What's Changed

Full Changelog: v2.0.1...v2.0.2

v2.0.1

Choose a tag to compare

@keichi keichi released this 28 Sep 04:54

v2.0.0

Choose a tag to compare

@keichi keichi released this 26 Sep 14:34

This release contains two backward incompatible changes:

  • Internet Explorer 11 and Node.js 10 or lower are unsupported. You might be able to make it work by using polyfills for TextDecoder and BigInt, but it is untested and unsupported.
  • Context variables are disabled by default due to their performance penalty and need to be explicitly enabled by calling .useContextVars() on the parser object.

Changelog: