From 68aacde6001133422d5944424442f92959b846c0 Mon Sep 17 00:00:00 2001 From: Phil Hughes <me@iamphill.com> Date: Thu, 19 Mar 2020 11:39:03 +0000 Subject: [PATCH] Fix new file not being created in non-ascii character folders --- .../javascripts/repository/components/breadcrumbs.vue | 4 +++- .../repository/components/table/parent_row.vue | 4 ++-- .../unreleased/ph-encodeUriComponentNewDirectoryPath.yml | 5 +++++ .../repository/components/table/parent_row_spec.js | 9 +++++---- 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/ph-encodeUriComponentNewDirectoryPath.yml diff --git a/app/assets/javascripts/repository/components/breadcrumbs.vue b/app/assets/javascripts/repository/components/breadcrumbs.vue index 03766c4877e..6c58f48dc74 100644 --- a/app/assets/javascripts/repository/components/breadcrumbs.vue +++ b/app/assets/javascripts/repository/components/breadcrumbs.vue @@ -134,7 +134,9 @@ export default { }, { attrs: { - href: `${this.newBlobPath}/${this.currentPath ? escape(this.currentPath) : ''}`, + href: `${this.newBlobPath}/${ + this.currentPath ? encodeURIComponent(this.currentPath) : '' + }`, class: 'qa-new-file-option', }, text: __('New file'), diff --git a/app/assets/javascripts/repository/components/table/parent_row.vue b/app/assets/javascripts/repository/components/table/parent_row.vue index a5c6c9822fb..f9fcbc356e8 100644 --- a/app/assets/javascripts/repository/components/table/parent_row.vue +++ b/app/assets/javascripts/repository/components/table/parent_row.vue @@ -25,10 +25,10 @@ export default { const splitArray = this.path.split('/'); splitArray.pop(); - return splitArray.join('/'); + return splitArray.map(p => encodeURIComponent(p)).join('/'); }, parentRoute() { - return { path: `/-/tree/${escape(this.commitRef)}/${escape(this.parentPath)}` }; + return { path: `/-/tree/${escape(this.commitRef)}/${this.parentPath}` }; }, }, methods: { diff --git a/changelogs/unreleased/ph-encodeUriComponentNewDirectoryPath.yml b/changelogs/unreleased/ph-encodeUriComponentNewDirectoryPath.yml new file mode 100644 index 00000000000..27384e54e91 --- /dev/null +++ b/changelogs/unreleased/ph-encodeUriComponentNewDirectoryPath.yml @@ -0,0 +1,5 @@ +--- +title: Fix new file not being created in non-ascii character folders +merge_request: 26165 +author: +type: fixed diff --git a/spec/frontend/repository/components/table/parent_row_spec.js b/spec/frontend/repository/components/table/parent_row_spec.js index 904798e0b83..b4800112fee 100644 --- a/spec/frontend/repository/components/table/parent_row_spec.js +++ b/spec/frontend/repository/components/table/parent_row_spec.js @@ -31,10 +31,11 @@ describe('Repository parent row component', () => { }); it.each` - path | to - ${'app'} | ${'/-/tree/master/'} - ${'app/assets'} | ${'/-/tree/master/app'} - ${'app/assets#/test'} | ${'/-/tree/master/app/assets%23'} + path | to + ${'app'} | ${'/-/tree/master/'} + ${'app/assets'} | ${'/-/tree/master/app'} + ${'app/assets#/test'} | ${'/-/tree/master/app/assets%23'} + ${'app/assets#/test/world'} | ${'/-/tree/master/app/assets%23/test'} `('renders link in $path to $to', ({ path, to }) => { factory(path); -- 2.30.9