Fix URL encoding on Subsonic (#850)

* Revert "Encode credential for subsonic stream/coverart (#841)"

This reverts commit 8ec4551b46.

* Properly URL encode credentials on Subsonic

Previous commit (8ec4551b46) 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
This commit is contained in:
Mitja Ševerkar 2024-11-20 04:00:53 +01:00 committed by GitHub
parent fac1d3fb62
commit 8eb8290fc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 8 deletions

View file

@ -65,7 +65,7 @@ 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,
@ -73,7 +73,7 @@ export const SubsonicController: ControllerEndpoint = {
} 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,