diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-01-24 09:56:00 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-01-24 09:56:00 +0100 |
commit | b848062d881902cb09c3aa4aff3e8ec667d58513 (patch) | |
tree | edb8c2afc1b15e902bbb24b92d8d026642535ec2 | |
parent | 30a5758a95f612d00f9aed934819f16c67aceefc (diff) | |
download | nextcloud-server-b848062d881902cb09c3aa4aff3e8ec667d58513.tar.gz nextcloud-server-b848062d881902cb09c3aa4aff3e8ec667d58513.zip |
Parse backslash as directory separator in breadcrumb
This will parse backslashes as directory separators in breadcrumbs. Thus when accessing something like `/index.php/apps/files?dir=foo\foo` the breadcrumb will properly resolve this instead of showing `foo\foo`
Fixes https://github.com/owncloud/core/issues/13643
-rw-r--r-- | apps/files/js/breadcrumb.js | 1 | ||||
-rw-r--r-- | apps/files/tests/js/breadcrumbSpec.js | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js index 5cea2639c7d..364475e4a4f 100644 --- a/apps/files/js/breadcrumb.js +++ b/apps/files/js/breadcrumb.js @@ -67,6 +67,7 @@ * @param dir path to be displayed as breadcrumb */ setDirectory: function(dir) { + dir = dir.replace(/\\/g, '/'); dir = dir || '/'; if (dir !== this.dir) { this.dir = dir; diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js index 30784fd70ad..a26f0176f15 100644 --- a/apps/files/tests/js/breadcrumbSpec.js +++ b/apps/files/tests/js/breadcrumbSpec.js @@ -93,6 +93,31 @@ describe('OCA.Files.BreadCrumb tests', function() { expect($crumbs.eq(3).find('img').length).toEqual(0); expect($crumbs.eq(3).attr('data-dir')).toEqual('/somedir/with space/abc'); }); + it('Renders backslashes as regular directory separator', function() { + var $crumbs; + bc.setDirectory('/somedir\\with/mixed\\separators'); + $crumbs = bc.$el.find('.crumb'); + expect($crumbs.length).toEqual(5); + expect($crumbs.eq(0).find('a').attr('href')).toEqual('/#0'); + expect($crumbs.eq(0).find('img').length).toEqual(1); + expect($crumbs.eq(0).attr('data-dir')).toEqual('/'); + + expect($crumbs.eq(1).find('a').attr('href')).toEqual('/somedir#1'); + expect($crumbs.eq(1).find('img').length).toEqual(0); + expect($crumbs.eq(1).attr('data-dir')).toEqual('/somedir'); + + expect($crumbs.eq(2).find('a').attr('href')).toEqual('/somedir/with#2'); + expect($crumbs.eq(2).find('img').length).toEqual(0); + expect($crumbs.eq(2).attr('data-dir')).toEqual('/somedir/with'); + + expect($crumbs.eq(3).find('a').attr('href')).toEqual('/somedir/with/mixed#3'); + expect($crumbs.eq(3).find('img').length).toEqual(0); + expect($crumbs.eq(3).attr('data-dir')).toEqual('/somedir/with/mixed'); + + expect($crumbs.eq(4).find('a').attr('href')).toEqual('/somedir/with/mixed/separators#4'); + expect($crumbs.eq(4).find('img').length).toEqual(0); + expect($crumbs.eq(4).attr('data-dir')).toEqual('/somedir/with/mixed/separators'); + }); }); describe('Events', function() { it('Calls onClick handler when clicking on a crumb', function() { |