Skip to content

Commit

Permalink
Properly URL encode credentials on Subsonic
Browse files Browse the repository at this point in the history
Previous commit (8ec4551) has been reverted, as it has encoded even equal signs (=), and and signs (&), which should not have been encoded. Nextcloud Music has subsequently failed to receive separate username and password and has therefore failed whilst authenticating the user.

Example of URL beforehand:
https://cloud.example.com/index.php/apps/music/subsonic/rest/stream.view?id=track-4936&v=1.13.0&c=feishin_&u%3Dtest-test%40example.com%26p%3Dpassword

Example of URL now:
https://cloud.example.com/index.php/apps/music/subsonic/rest/stream.view?id=track-4936&v=1.13.0&c=feishin_&u=test-test%40example.com&p=password
  • Loading branch information
mytja committed Nov 20, 2024
1 parent 446f7e6 commit 71ca72e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/renderer/api/subsonic/subsonic-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ export const SubsonicController: ControllerEndpoint = {
const cleanServerUrl = `${url.replace(/\/$/, '')}/rest`;

if (body.legacy) {
credential = `u=${body.username}&p=${body.password}`;
credential = `u=${encodeURIComponent(body.username)}&p=${encodeURIComponent(body.password)}`;
credentialParams = {
p: body.password,
u: body.username,
};
} else {
const salt = randomString(12);
const hash = md5(body.password + salt);
credential = `u=${body.username}&s=${salt}&t=${hash}`;
credential = `u=${encodeURIComponent(body.username)}&s=${encodeURIComponent(salt)}&t=${encodeURIComponent(hash)}`;
credentialParams = {
s: salt,
t: hash,
Expand Down

0 comments on commit 71ca72e

Please sign in to comment.