Skip to content

Commit

Permalink
Fix url escaping
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
  • Loading branch information
skjnldsv committed Jan 23, 2020
1 parent c558dbf commit edbf769
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 43 deletions.
42 changes: 21 additions & 21 deletions js/viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer.js.map

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"dependencies": {
"@nextcloud/auth": "^1.2.1",
"@nextcloud/axios": "^1.3.1",
"@nextcloud/paths": "^1.1.0",
"@nextcloud/router": "^1.0.0",
"@nextcloud/vue": "^1.2.7",
"camelcase": "^5.3.1",
Expand Down
5 changes: 4 additions & 1 deletion src/services/FileInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/

import client from './DavClient'
import { encodePath } from '@nextcloud/paths'
import { genFileInfo } from '../utils/fileUtils'

/**
* Retrieve the files list
*
Expand All @@ -30,7 +32,7 @@ import { genFileInfo } from '../utils/fileUtils'
* @returns {Array} the file list
*/
export default async function(path, options) {
const response = await client.stat(path, Object.assign({
const response = await client.stat(encodePath(path), Object.assign({
data: `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
Expand Down Expand Up @@ -59,5 +61,6 @@ export default async function(path, options) {
</d:propfind>`,
details: true,
}, options))

return genFileInfo(response.data)
}
3 changes: 2 additions & 1 deletion src/services/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

import client from './DavClient'
import { encodePath } from '@nextcloud/paths'
import { genFileInfo } from '../utils/fileUtils'

/**
Expand All @@ -34,7 +35,7 @@ export default async function(path, options) {
// getDirectoryContents doesn't accept / for root
const fixedPath = path === '/' ? '' : path

const response = await client.getDirectoryContents(fixedPath, Object.assign({
const response = await client.getDirectoryContents(encodePath(fixedPath), Object.assign({
data: `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
Expand Down
19 changes: 1 addition & 18 deletions src/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@
import camelcase from 'camelcase'
import { isNumber } from './numberUtil'

/**
* Get an url encoded path
*
* @param {String} path the full path
* @returns {string} url encoded file path
*/
const encodeFilePath = function(path) {
const pathSections = (path.startsWith('/') ? path : `/${path}`).split('/')
let relativePath = ''
pathSections.forEach((section) => {
if (section !== '') {
relativePath += '/' + encodeURIComponent(section)
}
})
return relativePath
}

/**
* Extract dir and name from file path
*
Expand Down Expand Up @@ -119,4 +102,4 @@ const genFileInfo = function(obj) {
return fileInfo
}

export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo }
export { extractFilePaths, sortCompare, genFileInfo }

0 comments on commit edbf769

Please sign in to comment.