aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-11-15 16:53:41 -0600
committerGitHub <noreply@github.com>2026-11-15 16:53:41 -0600
commit0bfe5062ea6cc3d3dadef7c88497c2a15a573ece (patch)
treeb29f0a43c8bbe53dd58c0e1b16a3dff90b77d172
parent7d67dc1d6a452812981d6a0965c3a2e07737b726 (diff)
parentcbf32079d0f479b5f75f51cd24e04df33b2f4dd5 (diff)
downloadslskd-0bfe5062ea6cc3d3dadef7c88497c2a15a573ece.tar.gz
Merge pull request #1926 from slskd/more-bugs
More bugs
-rw-r--r--src/slskd/Common/Validation/FileDoesNotExistAttribute.cs2
-rw-r--r--src/slskd/Common/Validation/FileExistsAttribute.cs2
-rw-r--r--src/web/src/lib/files.js15
-rw-r--r--src/web/src/lib/rooms.js2
4 files changed, 15 insertions, 6 deletions
diff --git a/src/slskd/Common/Validation/FileDoesNotExistAttribute.cs b/src/slskd/Common/Validation/FileDoesNotExistAttribute.cs
index 9336b064..03f72d76 100644
--- a/src/slskd/Common/Validation/FileDoesNotExistAttribute.cs
+++ b/src/slskd/Common/Validation/FileDoesNotExistAttribute.cs
@@ -42,7 +42,7 @@ namespace slskd.Validation
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
- if (value != null)
+ if (value is not null && !string.IsNullOrEmpty(value.ToString()))
{
var file = Path.GetFullPath(value?.ToString());
diff --git a/src/slskd/Common/Validation/FileExistsAttribute.cs b/src/slskd/Common/Validation/FileExistsAttribute.cs
index 6fc50f63..bd7f1530 100644
--- a/src/slskd/Common/Validation/FileExistsAttribute.cs
+++ b/src/slskd/Common/Validation/FileExistsAttribute.cs
@@ -54,7 +54,7 @@ namespace slskd.Validation
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
- if (value != null)
+ if (value is not null && !string.IsNullOrEmpty(value.ToString()))
{
var file = Path.GetFullPath(value?.ToString());
diff --git a/src/web/src/lib/files.js b/src/web/src/lib/files.js
index 99a82b2c..cbd0bd3c 100644
--- a/src/web/src/lib/files.js
+++ b/src/web/src/lib/files.js
@@ -1,21 +1,30 @@
import api from './api';
+// paths may contain any unicode character, so they are encoded as UTF-8 before base64 (btoa only accepts Latin-1),
+// and the result is URL-encoded because base64 may contain '/', which would otherwise split the route
+
export const list = async ({ root, subdirectory = '' }) => {
const response = (
- await api.get(`/files/${root}/directories/${btoa(subdirectory)}`)
+ await api.get(
+ `/files/${root}/directories/${encodeURIComponent(btoa(String.fromCodePoint(...new TextEncoder().encode(subdirectory))))}`,
+ )
).data;
return response;
};
export const deleteDirectory = async ({ root, path }) => {
- const response = await api.delete(`/files/${root}/directories/${btoa(path)}`);
+ const response = await api.delete(
+ `/files/${root}/directories/${encodeURIComponent(btoa(String.fromCodePoint(...new TextEncoder().encode(path))))}`,
+ );
return response;
};
export const deleteFile = async ({ root, path }) => {
- const response = await api.delete(`/files/${root}/files/${btoa(path)}`);
+ const response = await api.delete(
+ `/files/${root}/files/${encodeURIComponent(btoa(String.fromCodePoint(...new TextEncoder().encode(path))))}`,
+ );
return response;
};
diff --git a/src/web/src/lib/rooms.js b/src/web/src/lib/rooms.js
index 35da6701..3c6c22cb 100644
--- a/src/web/src/lib/rooms.js
+++ b/src/web/src/lib/rooms.js
@@ -49,7 +49,7 @@ export const getUsers = async ({ roomName }) => {
};
export const join = async ({ roomName }) => {
- return api.post('/rooms/joined', roomName);
+ return api.post('/rooms/joined', JSON.stringify(roomName));
};
export const leave = async ({ roomName }) => {