Skip to content

Commit

Permalink
Merge pull request #40644 from nextcloud/fix/noid/encode-uri-trashbin…
Browse files Browse the repository at this point in the history
…-restore-files-delete-favorite

fix: encode uri for delete, restore and favorite
  • Loading branch information
ChristophWurst committed Sep 29, 2023
2 parents db6a53b + 4f70324 commit cfda046
Show file tree
Hide file tree
Showing 24 changed files with 37 additions and 34 deletions.
3 changes: 2 additions & 1 deletion apps/files/src/actions/favoriteAction.ts
Expand Up @@ -30,6 +30,7 @@ import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw'
import StarSvg from '@mdi/svg/svg/star.svg?raw'

import logger from '../logger.js'
import { encodePath } from '@nextcloud/paths'

// If any of the nodes is not favorited, we display the favorite action.
const shouldFavorite = (nodes: Node[]): boolean => {
Expand All @@ -39,7 +40,7 @@ const shouldFavorite = (nodes: Node[]): boolean => {
export const favoriteNode = async (node: Node, view: View, willFavorite: boolean): Promise<boolean> => {
try {
// TODO: migrate to webdav tags plugin
const url = generateUrl('/apps/files/api/v1/files') + node.path
const url = generateUrl('/apps/files/api/v1/files') + encodePath(node.path)
await axios.post(url, {
tags: willFavorite
? [window.OC.TAG_FAVORITE]
Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/services/Files.ts
Expand Up @@ -30,6 +30,7 @@ import { getCurrentUser } from '@nextcloud/auth'
import { getClient, rootPath } from './WebdavClient'
import { hashCode } from '../utils/hashUtils'
import logger from '../logger'
import { encodePath } from '@nextcloud/paths'

const client = getClient()

Expand All @@ -44,7 +45,7 @@ export const resultToNode = function(node: FileStat): File | Folder {
const permissions = davParsePermissions(props?.permissions)
const owner = getCurrentUser()?.uid as string

const source = generateRemoteUrl('dav' + rootPath + node.filename)
const source = generateRemoteUrl(encodePath('dav' + rootPath + node.filename))
const id = props?.fileid < 0
? hashCode(source)
: props?.fileid as number || 0
Expand Down
3 changes: 2 additions & 1 deletion apps/files_trashbin/src/actions/restoreAction.ts
Expand Up @@ -28,6 +28,7 @@ import axios from '@nextcloud/axios'
import History from '@mdi/svg/svg/history.svg?raw'

import logger from '../../../files/src/logger.js'
import { encodePath } from '@nextcloud/paths'

registerFileAction(new FileAction({
id: 'restore',
Expand All @@ -50,7 +51,7 @@ registerFileAction(new FileAction({

async exec(node: Node) {
try {
const destination = generateRemoteUrl(encodeURI(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`))
const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`))
await axios({
method: 'MOVE',
url: node.source,
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/src/services/trashbin.ts
Expand Up @@ -46,7 +46,7 @@ const resultToNode = function(node: FileStat): File | Folder {

const nodeData = {
id: node.props?.fileid as number || 0,
source: generateRemoteUrl('dav' + rootPath + node.filename),
source: generateRemoteUrl(encodePath('dav' + rootPath + node.filename)),
// do not show the mtime column
// mtime: new Date(node.lastmod),
mime: node.mime as string,
Expand Down
4 changes: 2 additions & 2 deletions dist/485-485.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/485-485.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_trashbin-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_trashbin-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_versions-files_versions.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_versions-files_versions.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/systemtags-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/systemtags-init.js.map

Large diffs are not rendered by default.

0 comments on commit cfda046

Please sign in to comment.