Skip to content

v2.0.0

Latest

Choose a tag to compare

@moonD4rk moonD4rk released this 20 Nov 09:38
489c957

A redesigned, minimal API and a decoder that locates pages and records through their sizes and offsets. Still Go 1.20, zero dependencies. From this release on, the v2 API changes only in backward-compatible ways.

go get github.com/moond4rk/binarycookies/v2@v2.0.0

Breaking changes

  • The module path is now github.com/moond4rk/binarycookies/v2
  • binarycookies.Decode(r) replaces New(r).Decode() and returns *File; use .Pages or .Cookies()
  • Cookie fields are string instead of []byte, Secure() / HTTPOnly() are methods over the raw Flags, Creation is now Created, and times are in UTC
  • Removed BinaryCookies, Page.Length, Page.Offsets, Cookie.Size and Cookie.String()

See the migration guide.

Fixed

  • Flags are read bit by bit. Current Safari writes flag values such as 0x4205, which v1 decoded as neither Secure nor HttpOnly, so every cookie lost both attributes
  • A cookie record larger than 4096 bytes no longer makes the whole file fail to decode
  • Page sizes and cookie/string offsets are honored, so padding is no longer misread without an error
  • The comment no longer keeps its NUL terminator
  • NaN or out-of-range timestamps decode to the zero time on every platform instead of platform-dependent values
  • Allocation stays proportional to the input; a crafted 4 MiB file no longer allocates about 260 MiB
  • A truncated file reports io.ErrUnexpectedEOF instead of io.EOF

Added

  • Encode, which writes Safari's layout byte for byte
  • ErrInvalidSignature and ErrMalformed; a truncated file also matches io.ErrUnexpectedEOF

Tests & CI

  • Golden files for the Safari samples, table-driven tests for every decoding rule, and two fuzz targets
  • CI on Linux, macOS and Windows with Go 1.20 and the latest Go, plus linux/386, fuzzing and an API compatibility check
  • Verified against real Safari and WebKit data: 37 cookie files and 313 cookies decode, with v1 and v2 agreeing on everything except the corrected Secure/HttpOnly flags

What's Changed

  • feat: release v2 with a redesigned API and decoder by @moonD4rk in #4

Full Changelog: v1.0.3...v2.0.0