diff --git a/.gitignore b/.gitignore index 63a34beb978d4..0811a12f44bab 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ nbproject /build/lib/ /build/jsdocs/ /npm-debug.log +/PhantomJS_* # puphpet puphpet diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 14a5edb2d701d..607c82b7d226c 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1400,6 +1400,10 @@ return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); }, + /** + * @param {string} path + * @returns {boolean} + */ _isValidPath: function(path) { var sections = path.split('/'); for (var i = 0; i < sections.length; i++) { @@ -1407,7 +1411,9 @@ return false; } } - return true; + + return path.toLowerCase().indexOf(decodeURI('%0a')) === -1 && + path.toLowerCase().indexOf(decodeURI('%00')) === -1; }, /** diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 99a2ff9a5e20a..82b70141b72bf 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1379,9 +1379,11 @@ describe('OCA.Files.FileList tests', function() { '/abc/..', '/abc/../', '/../abc/', + '/foo%0Abar/', + '/foo%00bar/', '/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../' ], function(path) { - fileList.changeDirectory(path); + fileList.changeDirectory(decodeURI(path)); expect(fileList.getCurrentDirectory()).toEqual('/'); }); });