Merge pull request #564 from zachwn/headerEncoding

This commit is contained in:
Bill Thornton 2023-09-26 23:19:57 -04:00 committed by GitHub
commit 96f6d0262b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(', ');
}