Match for /../

This commit is contained in:
Lukas Reschke 2016-07-01 15:00:31 +02:00
parent 2da43e3751
commit 8aa0832bd4
No known key found for this signature in database
GPG Key ID: 9AB0ADB949B6898C
2 changed files with 5 additions and 1 deletions

View File

@ -1333,7 +1333,7 @@
* @param changeUrl true to also update the URL, false otherwise (default)
*/
_setCurrentDir: function(targetDir, changeUrl) {
targetDir = targetDir.replace(/\\/g, '/').replace(/\.\.\//g, '');
targetDir = targetDir.replace(/\\/g, '/').replace(/\/\.\.\//g, '/');
var previousDir = this.getCurrentDirectory(),
baseDir = OC.basename(targetDir);

View File

@ -1327,6 +1327,10 @@ describe('OCA.Files.FileList tests', function() {
fileList.changeDirectory('/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../');
expect(fileList.getCurrentDirectory()).toEqual('/another/subdir/foo/bar/file/folder/');
});
it('does not convert folders with a ".." in the name', function() {
fileList.changeDirectory('/abc../def');
expect(fileList.getCurrentDirectory()).toEqual('/abc../def');
});
it('switches to root dir when current directory does not exist', function() {
fileList.changeDirectory('/unexist');
deferredList.reject(404);