UNPKG

@lou.codes/parsers

Version:

👁️‍🗨️ Parsers without nonsense

20 lines (19 loc) 608 B
/** * Custom reviver that omits `"__proto__"` for safer parsing. * * @category JSON * @remarks * JSON parsing has a proto poisoning vulnerability that can be exploited by * passing a JSON string with a `__proto__` key. This reviver can be used to * prevent that. * @example * ```typescript * JSON.parse('{"__proto__":"😈"}', omitProto); // {} * ``` * @see {@link parseJSON} * * @param key Current key. * @param value Current value. * @returns The current value or `undefined` if the key is `"__proto__"`. */ export declare const omitProtoReviver: (key: string, value: unknown) => unknown;