Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion finder-template-generator-ssg/src/configeditor/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,26 @@ export function initConfigEditor(

function setPath(obj: any, path: string, value: unknown) {
const parts = path.split(".");
const isUnsafeKey = (key: string) =>
key === "__proto__" || key === "constructor" || key === "prototype";

let cur = obj;
for (let i = 0; i < parts.length - 1; i++) {
const p = parts[i];
if (isUnsafeKey(p)) {
throw new Error(`initConfigEditor: Unsicherer Pfad-Segmentname "${p}".`);
}
if (typeof cur[p] !== "object" || cur[p] === null) cur[p] = {};
cur = cur[p];
}
cur[parts[parts.length - 1]] = value;

const last = parts[parts.length - 1];
if (isUnsafeKey(last)) {
throw new Error(
`initConfigEditor: Unsicherer finaler Pfad-Segmentname "${last}".`,
);
}
cur[last] = value;
}

function readField(
Expand Down
Loading