Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(files): Properly encode URLs when preparing ZIP download
Signed-off-by: Fabian Zwemke <[email protected]>
  • Loading branch information
fabianzw committed Mar 26, 2025
commit 9fd0d263ff95f4f6c5b635f2b4ad3d1b92ad85a1
6 changes: 3 additions & 3 deletions apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ const downloadNodes = function(nodes: Node[]) {
url.searchParams.append('accept', 'zip')
}
} else {
url = new URL(nodes[0].source)
url = new URL(nodes[0].encodedSource)
let base = url.pathname
for (const node of nodes.slice(1)) {
base = longestCommonPath(base, (new URL(node.source).pathname))
base = longestCommonPath(base, (new URL(node.encodedSource).pathname))
Comment on lines +58 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this path as the URL constructor should already encode the URL so this smells like double encoding. Will test tomorrow with some more examples.

}
url.pathname = base

// The URL contains the path encoded so we need to decode as the query.append will re-encode it
const filenames = nodes.map((node) => decodeURI(node.encodedSource.slice(url.href.length + 1)))
const filenames = nodes.map((node) => decodeURIComponent(node.encodedSource.slice(url.href.length + 1)))
url.searchParams.append('accept', 'zip')
url.searchParams.append('files', JSON.stringify(filenames))
}
Expand Down