MCPcopy
hub / github.com/directus/directus / parseJSON

Function parseJSON

packages/utils/shared/parse-json.ts:4–10  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

2 * Run JSON.parse, but ignore `__proto__` properties. This prevents prototype pollution attacks
3 */
4export function parseJSON(input: string): any {
5 if (String(input).includes('__proto__')) {
6 return JSON.parse(input, noproto);
7 }
8
9 return JSON.parse(input);
10}
11
12export function noproto<T>(key: string, value: T): T | void {
13 if (key !== '__proto__') {

Callers 15

parse-json.test.tsFile · 0.90
isValidJSONFunction · 0.90
optionToObjectFunction · 0.90
parseFilterEntryFunction · 0.90
deserializeFunction · 0.90
tryJsonFunction · 0.90
formatQueryFunction · 0.90
getStringifiedValueFunction · 0.90
executeOperationMethod · 0.90
assets.tsFile · 0.90
schemaMultipartHandlerFunction · 0.90
sanitizeAggregateFunction · 0.90

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected