diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-08-12 21:13:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-12 21:13:18 -0500 |
| commit | 30178a042dbbeafe922cfa64e0a6066ff548cd6a (patch) | |
| tree | 36fcee016d0b9367be87d1708ea3a2dcf05958eb /src | |
| parent | e3b89745f0d1d18608d7183cb2af9e45c54d139e (diff) | |
| parent | 7b5cb93202b8c767f4cbb6dc67b4d942083e458a (diff) | |
| download | slskd-30178a042dbbeafe922cfa64e0a6066ff548cd6a.tar.gz | |
Merge pull request #585 from slskd/encode
Fix bug with unescaped values in some API calls
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/lib/chat.js | 6 | ||||
| -rw-r--r-- | src/web/src/lib/shares.js | 4 | ||||
| -rw-r--r-- | src/web/src/lib/transfers.js | 9 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/web/src/lib/chat.js b/src/web/src/lib/chat.js index e0205f4c..2b31bcd8 100644 --- a/src/web/src/lib/chat.js +++ b/src/web/src/lib/chat.js @@ -5,13 +5,13 @@ export const getAll = async () => { }; export const acknowledge = ({ username }) => { - return api.put(`/conversations/${username}`); + return api.put(`/conversations/${encodeURIComponent(username)}`); }; export const send = ({ username, message }) => { - return api.post(`/conversations/${username}`, JSON.stringify(message)); + return api.post(`/conversations/${encodeURIComponent(username)}`, JSON.stringify(message)); }; export const remove = ({ username }) => { - return api.delete(`/conversations/${username}`); + return api.delete(`/conversations/${encodeURIComponent(username)}`); };
\ No newline at end of file diff --git a/src/web/src/lib/shares.js b/src/web/src/lib/shares.js index f1d0373c..03fac7d6 100644 --- a/src/web/src/lib/shares.js +++ b/src/web/src/lib/shares.js @@ -6,7 +6,7 @@ export const getAll = async () => { export const get = async ({ id } = {}) => { if (!id) throw new Error('unable to get share: id is missing'); - return (await api.get(`/shares/${id}`)).data; + return (await api.get(`/shares/${encodeURIComponent(id)}`)).data; }; export const browseAll = async () => { @@ -15,7 +15,7 @@ export const browseAll = async () => { export const browse = async ({ id } = {}) => { if (!id) throw new Error('unable to get share contents: id is missing'); - return (await api.get(`/shares/${id}/contents`)).data; + return (await api.get(`/shares/${encodeURIComponent(id)}/contents`)).data; }; export const rescan = async () => { diff --git a/src/web/src/lib/transfers.js b/src/web/src/lib/transfers.js index d78a0ee8..f9815d4d 100644 --- a/src/web/src/lib/transfers.js +++ b/src/web/src/lib/transfers.js @@ -1,7 +1,7 @@ import api from './api'; export const getAll = async ({ direction }) => { - const response = (await api.get(`/transfers/${direction}s`)).data; + const response = (await api.get(`/transfers/${encodeURIComponent(direction)}s`)).data; if (!Array.isArray(response)) { console.warn('got non-array response from transfers API', response); @@ -12,11 +12,12 @@ export const getAll = async ({ direction }) => { }; export const download = ({ username, files = [] }) => { - return api.post(`/transfers/downloads/${username}`, files); + return api.post(`/transfers/downloads/${encodeURIComponent(username)}`, files); }; export const cancel = ({ direction, username, id, remove = false }) => { - return api.delete(`/transfers/${direction}s/${username}/${id}?remove=${remove}`); + return api.delete( + `/transfers/${direction}s/${encodeURIComponent(username)}/${encodeURIComponent(id)}?remove=${remove}`); }; // 'Requested' @@ -31,7 +32,7 @@ export const cancel = ({ direction, username, id, remove = false }) => { // 'Completed, Rejected' export const getPlaceInQueue = ({ username, id }) => { - return api.get(`/transfers/downloads/${username}/${id}/position`); + return api.get(`/transfers/downloads/${encodeURIComponent(username)}/${encodeURIComponent(id)}/position`); }; export const isStateRetryable = (state) => |
