Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9dc6ca2
feat: add validation for DecodeOptions and EncodeOptions to ensure pr…
techouse Feb 1, 2026
06fa2a0
fix: enhance decoding logic for ByteBuffer to handle malformed UTF-8 …
techouse Feb 1, 2026
e93edd5
feat: add throwOnLimitExceeded option to DecodeOptions for stricter l…
techouse Feb 1, 2026
121c8c7
test: add tests for throwOnLimitExceeded in DecodeOptions copyWith me…
techouse Feb 1, 2026
8840069
feat: implement _EncodeFrame and refactor encoding logic for improved…
techouse Feb 1, 2026
a446970
test: enhance tests for DecodeOptions and EncodeOptions with runtime …
techouse Feb 1, 2026
040ea89
refactor: move _EncodeFrame class to a separate file for better organ…
techouse Feb 1, 2026
5561626
docs: expand _EncodeFrame with additional properties for enhanced enc…
techouse Feb 1, 2026
fd5a91b
refactor: replace _validateDecodeOptions function with validate metho…
techouse Feb 1, 2026
f157c7f
refactor: add validation in DecodeOptions constructor to ensure prope…
techouse Feb 1, 2026
9b75955
refactor: enhance UTF-8 decoding in Utils to allow for malformed sequ…
techouse Feb 1, 2026
124961e
refactor: simplify test description for allowDots and decodeDotInKeys…
techouse Feb 1, 2026
14ff67b
refactor: introduce _MergePhase and _MergeFrame for improved merge ha…
techouse Feb 1, 2026
5bb177c
refactor: enhance DecodeOptions with runtime validation and assertion…
techouse Feb 8, 2026
be760ac
refactor: enhance merge handling in Utils by normalizing undefined va…
techouse Feb 8, 2026
db24759
refactor: rename _MergeFrame and _MergePhase to MergeFrame and MergeP…
techouse Feb 8, 2026
5a400fc
refactor: rename _EncodeFrame to EncodeFrame for improved clarity and…
techouse Feb 8, 2026
65f7c15
refactor: add comment to clarify Expando usage in DecodeOptions valid…
techouse Feb 8, 2026
e0a0518
refactor: add runtime validation for charset in encoding function
techouse Feb 8, 2026
d6750dd
refactor: update encoder documentation to clarify iterative stack-bas…
techouse Feb 8, 2026
7cd71fc
refactor: update import statement for DecodeOptions to use the correc…
techouse Feb 8, 2026
263f5ff
refactor: enhance comment for UTF-8 decoding to clarify Node.js compa…
techouse Feb 8, 2026
93a82ba
refactor: remove StateError from expected exceptions in decode tests
techouse Feb 8, 2026
cb1519e
refactor: create new merged lists and sets instead of mutating existi…
techouse Feb 9, 2026
7a42791
refactor: streamline merging logic for lists and sets in Utils class
techouse Feb 9, 2026
4c1e8c4
refactor: add validation for merge phase in Utils class
techouse Feb 9, 2026
2e6d9be
refactor: optimize iterable handling in encoding extension
techouse Feb 9, 2026
e9d8982
refactor: enhance encoding and decoding tests with additional cases
techouse Feb 9, 2026
d9cbe63
refactor: enhance merging logic to handle Undefined values in Utils c…
techouse Feb 9, 2026
adb8e92
refactor: change result variable declaration to late initialization i…
techouse Feb 9, 2026
15cb9c5
refactor: replace _FakeEncoding with FakeEncoding in tests and add fa…
techouse Feb 9, 2026
1dd3ac9
chore: update CHANGELOG for 1.7.0-wip with new features, fixes, and e…
techouse Feb 9, 2026
8fbc9d0
docs: enhance AI assistant guide with additional details on encoding …
techouse Feb 9, 2026
fcdc598
fix: decode ByteBuffer via charset when no custom encoder is provided
techouse Feb 9, 2026
67c0c84
chore: updated the runtime validation to use ArgumentError.value(...)…
techouse Feb 9, 2026
cf2a7ff
chore: replace assertion with ArgumentError in charset validation
techouse Feb 9, 2026
072c87d
chore: update CHANGELOG with new fixes for ByteBuffer decoding and ch…
techouse Feb 9, 2026
5192fba
Update lib/src/models/decode_options.dart
techouse Feb 9, 2026
bac8d33
Update lib/src/utils.dart
techouse Feb 9, 2026
bceff99
chore: improve error messages in EncodeOptions validation
techouse Feb 9, 2026
409599c
fix: correct typo in CHANGELOG for ByteBuffer encoding description
techouse Feb 9, 2026
da20f31
docs: add note about ByteBuffer decoding behavior in README
techouse Feb 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ Purpose: Provide just enough project context so an AI assistant can make correct
* Decode limits: default `depth=5`, `parameterLimit=1000`, `listLimit=20`; exceeding may coerce indices into object keys or (with strict flags) throw.
* List vs Map merging mimics Node: duplicate keys accumulate to lists unless `duplicates` option changes strategy.
* `Undefined` entries are placeholders stripped by `Utils.compact` post‑decode / during encode pruning; never serialize `Undefined` itself.
* `Utils.encode` uses `allowMalformed: true` when decoding `ByteBuffer` as UTF‑8 to match Node `Buffer.toString('utf8')`.
* Charset sentinel: when `charsetSentinel=true`, `utf8=✓` token (encoded differently per charset) overrides provided `charset` and is omitted from output.
* `allowDots` & `decodeDotInKeys`: invalid combination (`decodeDotInKeys: true` with `allowDots: false`) must throw (constructor asserts). Preserve that invariant.
* Merge semantics: list holes are treated as missing values when merging list‑of‑maps by index (no `[Undefined, map]` pair at an index); `parseLists=false` normalizes list results into string‑key maps.
* Negative `listLimit` disables numeric indexing; with `throwOnLimitExceeded` certain pushes must throw `RangeError` (match existing patterns in decode logic—consult decode part file before altering behavior).
* Encoding pipeline can inject custom encoder/decoder hooks; preserve argument order and named params (`charset`, `format`, `kind`).

Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.7.0-wip

* [FEAT] add `DecodeOptions.throwOnLimitExceeded` for strict limit enforcement on parameter, list, and depth overflows
* [FIX] tolerate malformed UTF-8 when encoding `ByteBuffer` values to match Node `Buffer.toString('utf8')`
* [FIX] encode `ByteBuffer` values via charset even when `encode=false` (avoid `Instance of 'ByteBuffer'` output)
* [FIX] ensure invalid charset in `Utils.encode` consistently throws `ArgumentError`
* [FIX] improve merge semantics for lists/maps (hole replacement, undefined normalization under `parseLists=false`, and non-mutating list/set merges)
* [FIX] add runtime validation and DecodeOptions constructor asserts for invalid charsets and inconsistent dot options
* [CHORE] refactor encode/merge internals to stack-based frames (`EncodeFrame`, `MergeFrame`, `MergePhase`) for deep-nesting safety
* [CHORE] expand coverage for encode/decode/merge edge cases and add a shared `FakeEncoding` test helper

## 1.6.1

* [FIX] prevent `DecodeOptions.listLimit` bypass in bracket notation to mitigate potential DoS via memory exhaustion
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ expect(
);
```

Note: when a value is a `ByteBuffer`, it is still decoded using the selected
charset even when `encode` is `false`, so the emitted value reflects the buffer
contents.

Encoding can be disabled for keys by setting the [EncodeOptions.encodeValuesOnly] option to `true`:

```dart
Expand Down
17 changes: 17 additions & 0 deletions lib/src/enums/merge_phase.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:meta/meta.dart' show internal;

/// Internal phases for the iterative merge walker.
///
/// These drive the state machine used by [Utils.merge] to avoid recursion
/// while preserving `qs` merge semantics for maps and iterables.
@internal
enum MergePhase {
/// Initial dispatch and shape normalization.
start,

/// Iterating over map entries during a merge step.
mapIter,

/// Iterating over list/set indices during a merge step.
listIter,
}
Loading