mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Protect against node types with reserved names such as toString
Fixes #880
This commit is contained in:
		@@ -105,7 +105,7 @@ module.exports = {
 | 
				
			|||||||
        config.forEach(function(n) {
 | 
					        config.forEach(function(n) {
 | 
				
			||||||
            if (n.type !== 'subflow' && n.type !== 'tab') {
 | 
					            if (n.type !== 'subflow' && n.type !== 'tab') {
 | 
				
			||||||
                for (var prop in n) {
 | 
					                for (var prop in n) {
 | 
				
			||||||
                    if (n.hasOwnProperty(prop) && prop !== 'id' && prop !== 'wires' && prop !== '_users' && flow.configs[n[prop]]) {
 | 
					                    if (n.hasOwnProperty(prop) && prop !== 'id' && prop !== 'wires' && prop !== 'type' && prop !== '_users' && flow.configs[n[prop]]) {
 | 
				
			||||||
                        // This property references a global config node
 | 
					                        // This property references a global config node
 | 
				
			||||||
                        flow.configs[n[prop]]._users.push(n.id)
 | 
					                        flow.configs[n[prop]]._users.push(n.id)
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -223,7 +223,7 @@ function removeModule(module) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function getNodeInfo(typeOrId) {
 | 
					function getNodeInfo(typeOrId) {
 | 
				
			||||||
    var id = typeOrId;
 | 
					    var id = typeOrId;
 | 
				
			||||||
    if (nodeTypeToId[typeOrId]) {
 | 
					    if (nodeTypeToId.hasOwnProperty(typeOrId)) {
 | 
				
			||||||
        id = nodeTypeToId[typeOrId];
 | 
					        id = nodeTypeToId[typeOrId];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* istanbul ignore else */
 | 
					    /* istanbul ignore else */
 | 
				
			||||||
@@ -248,7 +248,7 @@ function getFullNodeInfo(typeOrId) {
 | 
				
			|||||||
    // Used by index.enableNodeSet so that .file can be retrieved to pass
 | 
					    // Used by index.enableNodeSet so that .file can be retrieved to pass
 | 
				
			||||||
    // to loader.loadNodeSet
 | 
					    // to loader.loadNodeSet
 | 
				
			||||||
    var id = typeOrId;
 | 
					    var id = typeOrId;
 | 
				
			||||||
    if (nodeTypeToId[typeOrId]) {
 | 
					    if (nodeTypeToId.hasOwnProperty(typeOrId)) {
 | 
				
			||||||
        id = nodeTypeToId[typeOrId];
 | 
					        id = nodeTypeToId[typeOrId];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* istanbul ignore else */
 | 
					    /* istanbul ignore else */
 | 
				
			||||||
@@ -348,7 +348,7 @@ function inheritNode(constructor) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function registerNodeConstructor(nodeSet,type,constructor) {
 | 
					function registerNodeConstructor(nodeSet,type,constructor) {
 | 
				
			||||||
    if (nodeConstructors[type]) {
 | 
					    if (nodeConstructors.hasOwnProperty(type)) {
 | 
				
			||||||
        throw new Error(type+" already registered");
 | 
					        throw new Error(type+" already registered");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //TODO: Ensure type is known - but doing so will break some tests
 | 
					    //TODO: Ensure type is known - but doing so will break some tests
 | 
				
			||||||
@@ -440,7 +440,11 @@ function clear() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getTypeId(type) {
 | 
					function getTypeId(type) {
 | 
				
			||||||
    return nodeTypeToId[type];
 | 
					    if (nodeTypeToId.hasOwnProperty(type)) {
 | 
				
			||||||
 | 
					        return nodeTypeToId[type];
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function enableNodeSet(typeOrId) {
 | 
					function enableNodeSet(typeOrId) {
 | 
				
			||||||
@@ -449,7 +453,7 @@ function enableNodeSet(typeOrId) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var id = typeOrId;
 | 
					    var id = typeOrId;
 | 
				
			||||||
    if (nodeTypeToId[typeOrId]) {
 | 
					    if (nodeTypeToId.hasOwnProperty(typeOrId)) {
 | 
				
			||||||
        id = nodeTypeToId[typeOrId];
 | 
					        id = nodeTypeToId[typeOrId];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    var config;
 | 
					    var config;
 | 
				
			||||||
@@ -471,7 +475,7 @@ function disableNodeSet(typeOrId) {
 | 
				
			|||||||
        throw new Error("Settings unavailable");
 | 
					        throw new Error("Settings unavailable");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    var id = typeOrId;
 | 
					    var id = typeOrId;
 | 
				
			||||||
    if (nodeTypeToId[typeOrId]) {
 | 
					    if (nodeTypeToId.hasOwnProperty(typeOrId)) {
 | 
				
			||||||
        id = nodeTypeToId[typeOrId];
 | 
					        id = nodeTypeToId[typeOrId];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    var config;
 | 
					    var config;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user