Merge pull request #1232 from nextcloud/backport-1224-do-not-allow-linebreak-in-paths-9
[stable9] Do not allow linebreaks and null bytes in paths
This commit is contained in:
commit
28a05a207d
|
@ -104,6 +104,7 @@ nbproject
|
|||
/build/lib/
|
||||
/build/jsdocs/
|
||||
/npm-debug.log
|
||||
/PhantomJS_*
|
||||
|
||||
# puphpet
|
||||
puphpet
|
||||
|
|
|
@ -1327,6 +1327,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++) {
|
||||
|
@ -1334,7 +1338,9 @@
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
return path.toLowerCase().indexOf(decodeURI('%0a')) === -1 &&
|
||||
path.toLowerCase().indexOf(decodeURI('%00')) === -1;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1333,9 +1333,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('/');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue