Skip to content

Commit 0eb59a0

Browse files
authored
Avoid infinite loop with duplicate counting (#1095)
1 parent e3c7b26 commit 0eb59a0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

papaparse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ License: MIT
17451745
if (config.header && !baseIndex && data.length && !headerParsed)
17461746
{
17471747
const result = data[0];
1748-
const headerCount = {}; // To track the count of each base header
1748+
const headerCount = Object.create(null); // To track the count of each base header
17491749
const usedHeaders = new Set(result); // To track used headers and avoid duplicates
17501750
let duplicateHeaders = false;
17511751

tests/test-cases.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,19 @@ var CORE_PARSER_TESTS = [
626626
}
627627
}
628628
},
629+
{
630+
description: "Duplicate header names with __proto__ field",
631+
input: '__proto__,__proto__,__proto__\n1,2,3',
632+
config: { header: true },
633+
expected: {
634+
data: [['__proto__', '__proto___1', '__proto___2'], ['1', '2', '3']],
635+
errors: [],
636+
meta: {
637+
renamedHeaders: {__proto___1: '__proto__', __proto___2: '__proto__'},
638+
cursor: 35
639+
}
640+
}
641+
},
629642
];
630643

631644
describe('Core Parser Tests', function() {

0 commit comments

Comments
 (0)