diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-07-07 19:29:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-07 19:29:43 +0200 |
commit | 2a1a3957b65e847d51c4c735acf033f7df29cba6 (patch) | |
tree | e53ac77b3dfa0d425b9ea8084420988a4d7054b7 /apps/files/js/filelist.js | |
parent | f5ed01617045a816977688a6c9e549fdf2dab509 (diff) | |
parent | beae00a5e5457c41994e54c7f0563245d9ccf5ce (diff) | |
download | nextcloud-server-2a1a3957b65e847d51c4c735acf033f7df29cba6.tar.gz nextcloud-server-2a1a3957b65e847d51c4c735acf033f7df29cba6.zip |
Merge pull request #333 from nextcloud/sync-master
Sync master
Diffstat (limited to 'apps/files/js/filelist.js')
-rw-r--r-- | apps/files/js/filelist.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 24a6f4ec6e2..f0b16a57886 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -513,7 +513,7 @@ * Event handler for when the URL changed */ _onUrlChanged: function(e) { - if (e && e.dir) { + if (e && _.isString(e.dir)) { this.changeDirectory(e.dir, false, true); } }, @@ -1397,6 +1397,16 @@ return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); }, + _isValidPath: function(path) { + var sections = path.split('/'); + for (var i = 0; i < sections.length; i++) { + if (sections[i] === '..') { + return false; + } + } + return true; + }, + /** * Sets the current directory name and updates the breadcrumb. * @param targetDir directory to display @@ -1404,7 +1414,11 @@ * @param {string} [fileId] file id */ _setCurrentDir: function(targetDir, changeUrl, fileId) { - targetDir = targetDir.replace(/\\/g, '/').replace(/\/\.\.\//g, '/'); + targetDir = targetDir.replace(/\\/g, '/'); + if (!this._isValidPath(targetDir)) { + targetDir = '/'; + changeUrl = true; + } var previousDir = this.getCurrentDirectory(), baseDir = OC.basename(targetDir); @@ -1415,6 +1429,9 @@ this.setPageTitle(); } + if (targetDir.length > 0 && targetDir[0] !== '/') { + targetDir = '/' + targetDir; + } this._currentDirectory = targetDir; // legacy stuff |