Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
4.1.2 - June 30 2026
4.2.0 - July 13 2026
=====================

* Address [security advisory `GHSA-v5mp-jgw5-2x6j`](https://github.com/BinaryMuse/toml-node/security/advisories/GHSA-v5mp-jgw5-2x6j) (CVE pending), in which a specially crafted TOML string could pollute `Object.prototype` process-wide..
* Address [security advisory `GHSA-82x6-q7mm-w9cf`](https://github.com/BinaryMuse/toml-node/security/advisories/GHSA-82x6-q7mm-w9cf) (CVE pending), in which deeply nested arrays or inline tables could overflow the call stack and crash the process with an uncatchable `RangeError`. Nesting is now bounded (default 500 levels), and input past the limit throws a normal parse error. The limit is configurable via `toml.parse(input, { maxDepth })`.

4.1.1 - March 31 2026
=====================
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ try {
}
```

### Nesting Depth Limit

To guard against stack overflow on maliciously deep input, arrays and inline tables may nest at most 500 levels deep by default; input past the limit throws a normal parse error. Adjust the limit with the `maxDepth` option:

```javascript
toml.parse(someTomlString, { maxDepth: 100 });
```

### Date/Time Values

Offset date-times are returned as JavaScript `Date` objects. Local date-times, local dates, and local times are returned as strings since they have no timezone information and can't be losslessly represented as `Date`:
Expand Down
11 changes: 10 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
declare module 'toml' {
export function parse(input: string): any;
export interface ParseOptions {
/**
* Maximum nesting depth for arrays and inline tables. Parsing input nested
* deeper than this throws a parse error rather than overflowing the stack.
* Defaults to 500.
*/
maxDepth?: number;
}

export function parse(input: string, options?: ParseOptions): any;
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ var parser = require('./lib/parser');
var compiler = require('./lib/compiler');

module.exports = {
parse: function(input) {
parse: function(input, options) {
var str = input.toString();
var nodes = parser.parse(str);
var nodes = parser.parse(str, options);
return compiler.compile(nodes, str);
}
};
Loading
Loading