Skip to content

Commit c3cc4b0

Browse files
committed
Backport quadratic complexity fix for !!omap
1 parent 33d05b5 commit c3cc4b0

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## 4.3.1 - 2026-07-31
10+
### Security
11+
- [backport] Remove quadratic complexity from `!!omap` duplicate key detection.
12+
13+
914
## 4.3.0 - 2026-06-27
1015
### Added
1116
- [backport] Added `maxTotalMergeKeys` (10000) loader option to limit the total number of

lib/type/omap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const _toString = Object.prototype.toString
88
function resolveYamlOmap (data) {
99
if (data === null) return true
1010

11-
const objectKeys = []
11+
const objectKeys = {}
1212
const object = data
1313

1414
for (let index = 0, length = object.length; index < length; index += 1) {
@@ -27,8 +27,8 @@ function resolveYamlOmap (data) {
2727

2828
if (!pairHasKey) return false
2929

30-
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey)
31-
else return false
30+
if (_hasOwnProperty.call(objectKeys, pairKey)) return false
31+
Object.defineProperty(objectKeys, pairKey, { value: true })
3232
}
3333

3434
return true

test/spec/yaml-test-suite

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit da267a5c4782e7361e82889e76c0dc7df0e1e870

0 commit comments

Comments
 (0)