From effb061c5e1dbb7e0a6fe2c895af382b58fe9820 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 17 Mar 2015 23:40:56 +0400 Subject: [PATCH] make sure that broken paths are not added to fs.cache --- package.json | 4 ++-- plugins/c9.fs/fs.cache.xml.js | 11 ++++++++--- plugins/c9.fs/fs.js | 7 +++++++ plugins/c9.ide.tree/tree.js | 9 +++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7dda4a3d..af0866b5 100644 --- a/package.json +++ b/package.json @@ -57,9 +57,9 @@ "c9.ide.language.javascript": "#ec9ecf31cf", "c9.ide.language.javascript.immediate": "#9a2cce9121", "c9.ide.language.javascript.eslint": "#8832423ad1", - "c9.ide.language.javascript.tern": "#008c837519", + "c9.ide.language.javascript.tern": "#7aab8b0b6a", "c9.ide.language.javascript.infer": "#ebb2daf81a", - "c9.ide.language.jsonalyzer": "#3ae6c1545b", + "c9.ide.language.jsonalyzer": "#d82c60fcb9", "c9.ide.collab": "#b94018ab2b", "c9.ide.local": "#2bfd7ff051", "c9.ide.find": "#989c06e6a7", diff --git a/plugins/c9.fs/fs.cache.xml.js b/plugins/c9.fs/fs.cache.xml.js index 0d359039..fcc3b9d7 100644 --- a/plugins/c9.fs/fs.cache.xml.js +++ b/plugins/c9.fs/fs.cache.xml.js @@ -289,14 +289,14 @@ define(function(require, exports, module) { var newPath = e.args[1]; var parent = findNode(dirname(newPath)); - //Validation + // Validation var toNode = findNode(newPath); - if (parent) { //Dir is in cache + if (parent) { // Dir is in cache if (toNode) deleteNode(toNode); - createNode(newPath, null, node); // Move node + createNode(newPath, null, node); // Move node recurPathUpdate(node, oldPath, newPath); e.undo = function(){ @@ -480,6 +480,11 @@ define(function(require, exports, module) { } function createNode(path, stat, updateNode, updating) { + if (!/^[!~/]/.test(path)) { + var e = new Error("Refusing to add a node with misformed path to fs.cache"); + return reportError(e, { path: path }); + } + if (orphans[path]) { updateNode = orphans[path]; delete orphans[path]; diff --git a/plugins/c9.fs/fs.js b/plugins/c9.fs/fs.js index 11f66b81..cd8c8270 100644 --- a/plugins/c9.fs/fs.js +++ b/plugins/c9.fs/fs.js @@ -62,6 +62,13 @@ define(function(require, exports, module) { if (typeof args[args.length - 1] != "function") throw new Error("Missing callback for " + name); + + if (!/^[!~/]/.test(path)) { + var e = new Error("Invalid path passed to fs"); + e.data = { name: name, path: path }; + setTimeout(function() { throw e }); + return args[args.length - 1](e); + } var original_callback = args.pop(); diff --git a/plugins/c9.ide.tree/tree.js b/plugins/c9.ide.tree/tree.js index a0ed98ad..c63148eb 100644 --- a/plugins/c9.ide.tree/tree.js +++ b/plugins/c9.ide.tree/tree.js @@ -961,10 +961,15 @@ define(function(require, exports, module) { if (node === false || path.charAt(0) == "!") return increment(); + if (!/^[!~/]/.test(path)) { + console.error("invalid path", path); + delete expandedList[path]; + return increment(); + } + if (node && node.status == "loaded") { expandNode(node); - increment(); - return; + return increment(); } fs.readdir(path, function(err, data) {