Skip to content

Commit

Permalink
fix: stricter checking of key santization
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed May 2, 2024
1 parent 2e3f2b3 commit 343fe09
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ const reservedObjectProperties = new Set([
"toString",
"toJSON",
"valueOf",
"__proto__",
"prototype",
]);

/**
Expand Down Expand Up @@ -289,7 +291,7 @@ export const safeIdentifier = (name: string): string => {
};

export function checkSanitizeKey(key: string): boolean {
return typeof key === "string" && key !== "__proto__";
return typeof key === "string" && !!key.length && !reservedObjectProperties.has(key)
}

export function throwSanitizeKey(key: string) {
Expand Down

0 comments on commit 343fe09

Please sign in to comment.