diff --git a/ui/app/adapters/task-state.js b/ui/app/adapters/task-state.js index e4a08e40124c..f9f98ca6271e 100644 --- a/ui/app/adapters/task-state.js +++ b/ui/app/adapters/task-state.js @@ -6,13 +6,15 @@ export default ApplicationAdapter.extend({ ls(model, path) { return this.token - .authorizedRequest(`/v1/client/fs/ls/${model.allocation.id}?path=${path}`) + .authorizedRequest(`/v1/client/fs/ls/${model.allocation.id}?path=${encodeURIComponent(path)}`) .then(handleFSResponse); }, stat(model, path) { return this.token - .authorizedRequest(`/v1/client/fs/stat/${model.allocation.id}?path=${path}`) + .authorizedRequest( + `/v1/client/fs/stat/${model.allocation.id}?path=${encodeURIComponent(path)}` + ) .then(handleFSResponse); }, }); diff --git a/ui/app/components/fs-directory-entry.js b/ui/app/components/fs-directory-entry.js index 73a527421540..f50bb84560d3 100644 --- a/ui/app/components/fs-directory-entry.js +++ b/ui/app/components/fs-directory-entry.js @@ -7,7 +7,7 @@ export default Component.extend({ pathToEntry: computed('path', 'entry.Name', function() { const pathWithNoLeadingSlash = this.get('path').replace(/^\//, ''); - const name = this.get('entry.Name'); + const name = encodeURIComponent(this.get('entry.Name')); if (isEmpty(pathWithNoLeadingSlash)) { return name; diff --git a/ui/app/components/task-file.js b/ui/app/components/task-file.js index 4f982a7a63c8..03f4e52c4e09 100644 --- a/ui/app/components/task-file.js +++ b/ui/app/components/task-file.js @@ -49,7 +49,8 @@ export default Component.extend({ isStreaming: false, catUrl: computed('allocation.id', 'task.name', 'file', function() { - return `/v1/client/fs/cat/${this.allocation.id}?path=${this.task.name}/${this.file}`; + const encodedPath = encodeURIComponent(`${this.task.name}/${this.file}`); + return `/v1/client/fs/cat/${this.allocation.id}?path=${encodedPath}`; }), fetchMode: computed('isLarge', 'mode', function() { @@ -77,6 +78,7 @@ export default Component.extend({ ), fileParams: computed('task.name', 'file', 'mode', function() { + // The Log class handles encoding query params const path = `${this.task.name}/${this.file}`; switch (this.mode) { diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 9098e85fb981..c979f8c5d7a4 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -362,7 +362,8 @@ export default function() { const fileOrError = function(allocFiles, path, message = 'Operation not allowed on a directory') { // Ignore the task name at the beginning of the path - const filterPath = path.substr(path.indexOf('/') + 1); + const decodedPath = decodeURIComponent(path); + const filterPath = decodedPath.substr(decodedPath.indexOf('/') + 1); // Root path if (!filterPath) { diff --git a/ui/mirage/factories/alloc-file.js b/ui/mirage/factories/alloc-file.js index 6de58b6370a6..db9f4a9261f2 100644 --- a/ui/mirage/factories/alloc-file.js +++ b/ui/mirage/factories/alloc-file.js @@ -2,7 +2,7 @@ import { Factory, faker, trait } from 'ember-cli-mirage'; import { pickOne } from '../utils'; const REF_TIME = new Date(); -const TROUBLESOME_CHARACTERS = '🏆 💃 🤩 🙌🏿 🖨 ? / + ; %'.split(' '); +const TROUBLESOME_CHARACTERS = '🏆 💃 🤩 🙌🏿 🖨 ? ; %'.split(' '); const makeWord = () => Math.round(Math.random() * 10000000 + 50000).toString(36); const makeSentence = (count = 10) => new Array(count) diff --git a/ui/tests/acceptance/task-fs-test.js b/ui/tests/acceptance/task-fs-test.js index 4c3481d925f8..d8c4bc9949c3 100644 --- a/ui/tests/acceptance/task-fs-test.js +++ b/ui/tests/acceptance/task-fs-test.js @@ -298,7 +298,6 @@ module('Acceptance | task fs', function(hooks) { test('viewing a file', async function(assert) { const node = server.db.nodes.find(allocation.nodeId); - server.logging = true; server.get(`http://${node.httpAddr}/v1/client/fs/readat/:allocation_id`, function() { return new Response(500); }); diff --git a/ui/tests/integration/task-file-test.js b/ui/tests/integration/task-file-test.js index e23ef26fcdc6..05f944579dcb 100644 --- a/ui/tests/integration/task-file-test.js +++ b/ui/tests/integration/task-file-test.js @@ -132,7 +132,9 @@ module('Integration | Component | task file', function(hooks) { const rawLink = find('[data-test-log-action="raw"]'); assert.equal( rawLink.getAttribute('href'), - `/v1/client/fs/cat/${props.allocation.id}?path=${props.task.name}/${props.file}`, + `/v1/client/fs/cat/${props.allocation.id}?path=${encodeURIComponent( + `${props.task.name}/${props.file}` + )}`, 'Raw link href is correct' );