fix(files): encoded source path on actions requests

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
pull/40756/head
John Molakvoæ 8 months ago
parent 8f30f97642
commit d79e26b25a
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF

@ -44,7 +44,7 @@ export const action = new FileAction({
async exec(node: Node) { async exec(node: Node) {
try { try {
await axios.delete(node.source) await axios.delete(node.encodedSource)
// Let's delete even if it's moved to the trashbin // Let's delete even if it's moved to the trashbin
// since it has been removed from the current view // since it has been removed from the current view

@ -86,7 +86,7 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
} }
const relativePath = join(destination.path, node.basename) const relativePath = join(destination.path, node.basename)
const destinationUrl = generateRemoteUrl(`dav/files/${getCurrentUser()?.uid}${relativePath}`) const destinationUrl = generateRemoteUrl(encodePath(`dav/files/${getCurrentUser()?.uid}${relativePath}`))
logger.debug(`${method} ${node.basename} to ${destinationUrl}`) logger.debug(`${method} ${node.basename} to ${destinationUrl}`)
// Set loading state // Set loading state
@ -97,7 +97,7 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
try { try {
await axios({ await axios({
method: method === MoveCopyAction.COPY ? 'COPY' : 'MOVE', method: method === MoveCopyAction.COPY ? 'COPY' : 'MOVE',
url: encodeURI(node.source), url: node.encodedSource,
headers: { headers: {
Destination: encodeURI(destinationUrl), Destination: encodeURI(destinationUrl),
Overwrite: overwrite ? undefined : 'F', Overwrite: overwrite ? undefined : 'F',

@ -845,7 +845,7 @@ export default Vue.extend({
// Rename and move the file // Rename and move the file
async onRename() { async onRename() {
const oldName = this.source.basename const oldName = this.source.basename
const oldSource = this.source.source const oldEncodedSource = this.source.encodedSource
const newName = this.newName.trim?.() || '' const newName = this.newName.trim?.() || ''
if (newName === '') { if (newName === '') {
showError(this.t('files', 'Name cannot be empty')) showError(this.t('files', 'Name cannot be empty'))
@ -870,12 +870,13 @@ export default Vue.extend({
// Update node // Update node
this.source.rename(newName) this.source.rename(newName)
logger.debug('Moving file to', { destination: this.source.encodedSource, oldEncodedSource })
try { try {
await axios({ await axios({
method: 'MOVE', method: 'MOVE',
url: oldSource, url: oldEncodedSource,
headers: { headers: {
Destination: encodeURI(this.source.source), Destination: this.source.encodedSource,
}, },
}) })

@ -70,7 +70,7 @@ export const entry = {
async handler(context: Folder, content: Node[]) { async handler(context: Folder, content: Node[]) {
const contentNames = content.map((node: Node) => node.basename) const contentNames = content.map((node: Node) => node.basename)
const name = getUniqueName(t('files', 'New folder'), contentNames) const name = getUniqueName(t('files', 'New folder'), contentNames)
const { fileid, source } = await createNewFolder(context.source, name) const { fileid, source } = await createNewFolder(context.encodedSource, encodeURIComponent(name))
// Create the folder in the store // Create the folder in the store
const folder = new Folder({ const folder = new Folder({

@ -30,7 +30,6 @@ import { getCurrentUser } from '@nextcloud/auth'
import { getClient, rootPath } from './WebdavClient' import { getClient, rootPath } from './WebdavClient'
import { hashCode } from '../utils/hashUtils' import { hashCode } from '../utils/hashUtils'
import logger from '../logger' import logger from '../logger'
import { encodePath } from '@nextcloud/paths'
const client = getClient() const client = getClient()
@ -45,7 +44,7 @@ export const resultToNode = function(node: FileStat): File | Folder {
const permissions = davParsePermissions(props?.permissions) const permissions = davParsePermissions(props?.permissions)
const owner = getCurrentUser()?.uid as string const owner = getCurrentUser()?.uid as string
const source = generateRemoteUrl(encodePath('dav' + rootPath + node.filename)) const source = generateRemoteUrl('dav' + rootPath + node.filename)
const id = props?.fileid < 0 const id = props?.fileid < 0
? hashCode(source) ? hashCode(source)
: props?.fileid as number || 0 : props?.fileid as number || 0

@ -54,7 +54,7 @@ registerFileAction(new FileAction({
const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`)) const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`))
await axios({ await axios({
method: 'MOVE', method: 'MOVE',
url: node.source, url: node.encodedSource,
headers: { headers: {
destination, destination,
}, },

@ -46,7 +46,7 @@ const resultToNode = function(node: FileStat): File | Folder {
const nodeData = { const nodeData = {
id: node.props?.fileid as number || 0, id: node.props?.fileid as number || 0,
source: generateRemoteUrl(encodePath('dav' + rootPath + node.filename)), source: generateRemoteUrl('dav' + rootPath + node.filename),
// do not show the mtime column // do not show the mtime column
// mtime: new Date(node.lastmod), // mtime: new Date(node.lastmod),
mime: node.mime as string, mime: node.mime as string,

4
dist/5912-5912.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/core-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

33
package-lock.json generated

@ -19,7 +19,7 @@
"@nextcloud/capabilities": "^1.0.4", "@nextcloud/capabilities": "^1.0.4",
"@nextcloud/dialogs": "^5.0.0-beta.4", "@nextcloud/dialogs": "^5.0.0-beta.4",
"@nextcloud/event-bus": "^3.1.0", "@nextcloud/event-bus": "^3.1.0",
"@nextcloud/files": "^3.0.0-beta.22", "@nextcloud/files": "^3.0.0-beta.25",
"@nextcloud/initial-state": "^2.0.0", "@nextcloud/initial-state": "^2.0.0",
"@nextcloud/l10n": "^2.1.0", "@nextcloud/l10n": "^2.1.0",
"@nextcloud/logger": "^2.5.0", "@nextcloud/logger": "^2.5.0",
@ -3396,15 +3396,15 @@
"integrity": "sha512-rxzuSL2RSt/pWWnFnUFQi5GJArm2tHMhx20Gee3Ydn+xT2bqbR4syfgdPrq2b+j+n5LjC7C8Fb1QDM6LKeF0cA==" "integrity": "sha512-rxzuSL2RSt/pWWnFnUFQi5GJArm2tHMhx20Gee3Ydn+xT2bqbR4syfgdPrq2b+j+n5LjC7C8Fb1QDM6LKeF0cA=="
}, },
"node_modules/@nextcloud/auth": { "node_modules/@nextcloud/auth": {
"version": "2.1.0", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/@nextcloud/auth/-/auth-2.1.0.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/auth/-/auth-2.2.1.tgz",
"integrity": "sha512-wf5xQrWQu6fkl3MGegVdyR5mh/EdSQKJByH3m2Url2K2xbML9Y4Y7LAff9jjJAcMt2MkzzJEM463ZBbgTqs0lg==", "integrity": "sha512-zYtgrg9NMZfN8kmL5JPCsh5jDhpTCEslhnZWMvbhTiQ7hrOnji/67ok6VMK0CTJ1a92Vr67Ow72lW7YRX69zEA==",
"dependencies": { "dependencies": {
"@nextcloud/event-bus": "^3.1.0" "@nextcloud/event-bus": "^3.1.0"
}, },
"engines": { "engines": {
"node": "^16.0.0", "node": "^20.0.0",
"npm": "^7.0.0 || ^8.0.0" "npm": "^9.0.0"
} }
}, },
"node_modules/@nextcloud/axios": { "node_modules/@nextcloud/axios": {
@ -3662,13 +3662,14 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}, },
"node_modules/@nextcloud/files": { "node_modules/@nextcloud/files": {
"version": "3.0.0-beta.22", "version": "3.0.0-beta.25",
"resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-3.0.0-beta.22.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-3.0.0-beta.25.tgz",
"integrity": "sha512-Y/F3d3sigGJf/2HOTy8PLMgyQnVtMsQVUM+ul7GXgfdMPEVOpQViU9t6K37UjDAVu5v4CvKA++BVKt09KSGxwA==", "integrity": "sha512-Bw0PRxb3P4wAEybhubFWmlnVihDi2CTc/tQXayWvAz3cAUh8zBK2drnhsF7UQgJGJTZ4l2sdBhgXONUwab75kw==",
"dependencies": { "dependencies": {
"@nextcloud/auth": "^2.1.0", "@nextcloud/auth": "^2.2.1",
"@nextcloud/l10n": "^2.2.0", "@nextcloud/l10n": "^2.2.0",
"@nextcloud/logger": "^2.5.0", "@nextcloud/logger": "^2.7.0",
"@nextcloud/paths": "^2.1.0",
"@nextcloud/router": "^2.1.2", "@nextcloud/router": "^2.1.2",
"is-svg": "^5.0.0", "is-svg": "^5.0.0",
"webdav": "^5.3.0" "webdav": "^5.3.0"
@ -3704,16 +3705,16 @@
} }
}, },
"node_modules/@nextcloud/logger": { "node_modules/@nextcloud/logger": {
"version": "2.5.0", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/@nextcloud/logger/-/logger-2.5.0.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/logger/-/logger-2.7.0.tgz",
"integrity": "sha512-vJx5YxPyS9/tg3YoqA8CBN7YTZFHfuhMKJIIWFV28phxXqKhGwKVKh+/Ir8ZIPweIM5n8VNT6JOJq1JjGiMg2w==", "integrity": "sha512-DSJg9H1jT2zfr7uoP4tL5hKncyY+LOuxJzLauj0M/f6gnpoXU5WG1Zw8EFPOrRWjkC0ZE+NCqrMnITgdRRpXJQ==",
"dependencies": { "dependencies": {
"@nextcloud/auth": "^2.0.0", "@nextcloud/auth": "^2.0.0",
"core-js": "^3.6.4" "core-js": "^3.6.4"
}, },
"engines": { "engines": {
"node": "^16.0.0", "node": "^20.0.0",
"npm": "^7.0.0 || ^8.0.0" "npm": "^9.0.0"
} }
}, },
"node_modules/@nextcloud/moment": { "node_modules/@nextcloud/moment": {

@ -46,7 +46,7 @@
"@nextcloud/capabilities": "^1.0.4", "@nextcloud/capabilities": "^1.0.4",
"@nextcloud/dialogs": "^5.0.0-beta.4", "@nextcloud/dialogs": "^5.0.0-beta.4",
"@nextcloud/event-bus": "^3.1.0", "@nextcloud/event-bus": "^3.1.0",
"@nextcloud/files": "^3.0.0-beta.22", "@nextcloud/files": "^3.0.0-beta.25",
"@nextcloud/initial-state": "^2.0.0", "@nextcloud/initial-state": "^2.0.0",
"@nextcloud/l10n": "^2.1.0", "@nextcloud/l10n": "^2.1.0",
"@nextcloud/logger": "^2.5.0", "@nextcloud/logger": "^2.5.0",

Loading…
Cancel
Save