Skip to content

Commit

Permalink
Undoing some escaping stuff, only encoding URIs differently ...
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalopitz committed May 13, 2022
1 parent 3576e35 commit 631c8c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 16 additions & 9 deletions src/common/services/MusicServiceClient.js
Expand Up @@ -3,6 +3,7 @@ import get from 'lodash/get';
import isArray from 'lodash/isArray';
import includes from 'lodash/includes';
import padStart from 'lodash/padStart';
import escape from 'lodash/escape';

import moment from 'moment';
import { Helpers } from 'sonos';
Expand All @@ -15,7 +16,7 @@ import { withinEnvelope, stripNamespaces, NS } from '../../common/helpers';

const deviceProviderName = 'Sonos';

const __escape = (str) => encodeURIComponent(str);
const __escape = (str) => escape(str);

class MusicServiceClient {
constructor(serviceDefinition, { authToken, privateKey } = {}) {
Expand Down Expand Up @@ -101,7 +102,7 @@ class MusicServiceClient {
trackId.startsWith('spotify:track:') ||
trackId.startsWith('spotify:artistRadio:')
) {
return __escape(trackId);
return encodeURIComponent(trackId);
}
}

Expand All @@ -111,36 +112,42 @@ class MusicServiceClient {
itemType
)
) {
return 'x-rincon-cpcontainer:0006206c' + __escape(trackId);
return (
'x-rincon-cpcontainer:0006206c' + encodeURIComponent(trackId)
);
}

if (itemType === 'container') {
return `x-rincon-cpcontainer:10fe206c${__escape(
return `x-rincon-cpcontainer:10fe206c${encodeURIComponent(
trackId
)}?sid=${serviceId}&flags=8300&sn=1`;
}

if (itemType === 'trackList') {
return 'x-rincon-cpcontainer:000e206c' + __escape(trackId);
return (
'x-rincon-cpcontainer:000e206c' + encodeURIComponent(trackId)
);
}

if (itemType === 'album') {
return 'x-rincon-cpcontainer:0004206c' + __escape(trackId);
return (
'x-rincon-cpcontainer:0004206c' + encodeURIComponent(trackId)
);
}

if (itemType === 'program') {
return `x-sonosapi-radio:${__escape(
return `x-sonosapi-radio:${__esencodeURIComponentcape(
trackId
)}?sid=${serviceId}&flags=8296&sn=17`;
}

if (itemType === 'stream') {
return `x-sonosapi-stream:${__escape(
return `x-sonosapi-stream:${encodeURIComponent(
trackId
)}?sid=${serviceId}&flags=8224&sn=14`;
}

return `${protocol}:${__escape(
return `${protocol}:${encodeURIComponent(
trackId
)}${suffix}?sid=${serviceId}&flags=8224&sn=1`;
}
Expand Down
3 changes: 2 additions & 1 deletion src/localMusic/server.js
Expand Up @@ -10,6 +10,7 @@ import { getType } from 'mime';
import { Helpers } from 'sonos';

import get from 'lodash/get';
import escape from 'lodash/escape';

import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
Expand Down Expand Up @@ -57,7 +58,7 @@ const isAllowedDirectory = async (p) => {
return await isDirectoryAsync(p);
};

const __escape = (str) => encodeURIComponent(str);
const __escape = (str) => escape(str);

class SoapError extends Error {}

Expand Down

0 comments on commit 631c8c7

Please sign in to comment.