Skip to content

Commit

Permalink
Merge pull request #564 from zachwn/headerEncoding
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill authored Sep 27, 2023
2 parents baad1e1 + bcb0642 commit 96f6d02
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/utils/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import type { ClientInfo, DeviceInfo } from '../models';
* Returns a valid authorization header string.
*/
export function getAuthorizationHeader(clientInfo: ClientInfo, deviceInfo: DeviceInfo, accessToken = ''): string {
// TODO: We should ensure values are properly escaped
return [
`MediaBrowser Client="${clientInfo.name}"`,
`Device="${deviceInfo.name}"`,
`DeviceId="${deviceInfo.id}"`,
`Version="${clientInfo.version}"`,
`Token="${accessToken}"`
`MediaBrowser Client="${encodeURIComponent(clientInfo.name)}"`,
`Device="${encodeURIComponent(deviceInfo.name)}"`,
`DeviceId="${encodeURIComponent(deviceInfo.id)}"`,
`Version="${encodeURIComponent(clientInfo.version)}"`,
`Token="${encodeURIComponent(accessToken)}"`
].join(', ');
}

0 comments on commit 96f6d02

Please sign in to comment.