Filter out %0A from paths

This commit is contained in:
Joas Schilling 2016-09-01 10:06:06 +02:00
parent 4a5cd74fb2
commit 7cd86cfe59
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 8 additions and 2 deletions

View File

@ -1407,6 +1407,10 @@
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
}, },
/**
* @param {string} path
* @returns {boolean}
*/
_isValidPath: function(path) { _isValidPath: function(path) {
var sections = path.split('/'); var sections = path.split('/');
for (var i = 0; i < sections.length; i++) { for (var i = 0; i < sections.length; i++) {
@ -1414,7 +1418,8 @@
return false; return false;
} }
} }
return true;
return path.toLowerCase().indexOf(decodeURI('%0a')) === -1;
}, },
/** /**

View File

@ -1401,9 +1401,10 @@ describe('OCA.Files.FileList tests', function() {
'/abc/..', '/abc/..',
'/abc/../', '/abc/../',
'/../abc/', '/../abc/',
'/foo%0Abar/',
'/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../' '/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../'
], function(path) { ], function(path) {
fileList.changeDirectory(path); fileList.changeDirectory(decodeURI(path));
expect(fileList.getCurrentDirectory()).toEqual('/'); expect(fileList.getCurrentDirectory()).toEqual('/');
}); });
}); });