Skip to content

Commit 588234c

Browse files
committed
fix: encode uri for delete, restore and favorite
To encode # and other characters properly Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent bbfa9d1 commit 588234c

24 files changed

+37
-34
lines changed

apps/files/src/actions/favoriteAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw'
3030
import StarSvg from '@mdi/svg/svg/star.svg?raw'
3131

3232
import logger from '../logger.js'
33+
import { encodePath } from '@nextcloud/paths'
3334

3435
// If any of the nodes is not favorited, we display the favorite action.
3536
const shouldFavorite = (nodes: Node[]): boolean => {
@@ -39,7 +40,7 @@ const shouldFavorite = (nodes: Node[]): boolean => {
3940
export const favoriteNode = async (node: Node, view: View, willFavorite: boolean): Promise<boolean> => {
4041
try {
4142
// TODO: migrate to webdav tags plugin
42-
const url = generateUrl('/apps/files/api/v1/files') + node.path
43+
const url = generateUrl('/apps/files/api/v1/files') + encodePath(node.path)
4344
await axios.post(url, {
4445
tags: willFavorite
4546
? [window.OC.TAG_FAVORITE]

apps/files/src/services/Files.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { getCurrentUser } from '@nextcloud/auth'
3030
import { getClient, rootPath } from './WebdavClient'
3131
import { hashCode } from '../utils/hashUtils'
3232
import logger from '../logger'
33+
import { encodePath } from '@nextcloud/paths'
3334

3435
const client = getClient()
3536

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

47-
const source = generateRemoteUrl('dav' + rootPath + node.filename)
48+
const source = generateRemoteUrl(encodePath('dav' + rootPath + node.filename))
4849
const id = props?.fileid < 0
4950
? hashCode(source)
5051
: props?.fileid as number || 0

apps/files_trashbin/src/actions/restoreAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import axios from '@nextcloud/axios'
2828
import History from '@mdi/svg/svg/history.svg?raw'
2929

3030
import logger from '../../../files/src/logger.js'
31+
import { encodePath } from '@nextcloud/paths'
3132

3233
registerFileAction(new FileAction({
3334
id: 'restore',
@@ -50,7 +51,7 @@ registerFileAction(new FileAction({
5051

5152
async exec(node: Node) {
5253
try {
53-
const destination = generateRemoteUrl(encodeURI(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`))
54+
const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`))
5455
await axios({
5556
method: 'MOVE',
5657
url: node.source,

apps/files_trashbin/src/services/trashbin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const resultToNode = function(node: FileStat): File | Folder {
4646

4747
const nodeData = {
4848
id: node.props?.fileid as number || 0,
49-
source: generateRemoteUrl('dav' + rootPath + node.filename),
49+
source: generateRemoteUrl(encodePath('dav' + rootPath + node.filename)),
5050
// do not show the mtime column
5151
// mtime: new Date(node.lastmod),
5252
mime: node.mime as string,

dist/188-188.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/188-188.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)