mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Sanitize unknown node types on load to prevent XSS.
This commit is contained in:
parent
1ffa8858e7
commit
02f062b5b7
@ -5,6 +5,22 @@ import { api } from "./api.js";
|
|||||||
import { defaultGraph } from "./defaultGraph.js";
|
import { defaultGraph } from "./defaultGraph.js";
|
||||||
import { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo.js";
|
import { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo.js";
|
||||||
|
|
||||||
|
|
||||||
|
function sanitizeNodeName(string) {
|
||||||
|
let entityMap = {
|
||||||
|
'&': '',
|
||||||
|
'<': '',
|
||||||
|
'>': '',
|
||||||
|
'"': '',
|
||||||
|
"'": '',
|
||||||
|
'`': '',
|
||||||
|
'=': ''
|
||||||
|
};
|
||||||
|
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
||||||
|
return entityMap[s];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import("types/comfy").ComfyExtension} ComfyExtension
|
* @typedef {import("types/comfy").ComfyExtension} ComfyExtension
|
||||||
*/
|
*/
|
||||||
@ -1480,6 +1496,7 @@ export class ComfyApp {
|
|||||||
|
|
||||||
// Find missing node types
|
// Find missing node types
|
||||||
if (!(n.type in LiteGraph.registered_node_types)) {
|
if (!(n.type in LiteGraph.registered_node_types)) {
|
||||||
|
n.type = sanitizeNodeName(n.type);
|
||||||
missingNodeTypes.push(n.type);
|
missingNodeTypes.push(n.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user