Properly encode device name and related parameters

This commit is contained in:
Odd Stråbø 2025-09-12 02:52:30 +02:00
commit 7941eb4a9c
3 changed files with 15 additions and 13 deletions

View file

@ -63,8 +63,6 @@ def get_device_name():
device_name = xbmc.getInfoLabel("System.FriendlyName") device_name = xbmc.getInfoLabel("System.FriendlyName")
else: else:
device_name = settings("deviceName") device_name = settings("deviceName")
device_name = device_name.replace('"', "_")
device_name = device_name.replace("/", "_")
return device_name return device_name

View file

@ -2,6 +2,7 @@
from __future__ import division, absolute_import, print_function, unicode_literals from __future__ import division, absolute_import, print_function, unicode_literals
import json import json
from urllib.parse import quote
import requests import requests
@ -406,10 +407,10 @@ class API(object):
def get_default_headers(self): def get_default_headers(self):
auth = "MediaBrowser " auth = "MediaBrowser "
auth += "Client=%s, " % self.config.data["app.name"] auth += "Client=%s, " % quote(self.config.data["app.name"])
auth += "Device=%s, " % self.config.data["app.device_name"] auth += "Device=%s, " % quote(self.config.data["app.device_name"])
auth += "DeviceId=%s, " % self.config.data["app.device_id"] auth += "DeviceId=%s, " % quote(self.config.data["app.device_id"])
auth += "Version=%s" % self.config.data["app.version"] auth += "Version=%s" % quote(self.config.data["app.version"])
return { return {
"Accept": "application/json", "Accept": "application/json",

View file

@ -4,6 +4,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
################################################################################################# #################################################################################################
import time import time
from urllib.parse import quote
import requests import requests
@ -247,20 +248,22 @@ class HTTP(object):
def _authorization(self, data): def _authorization(self, data):
auth = "MediaBrowser " auth = "MediaBrowser "
auth += "Client=%s, " % self.config.data.get("app.name", "Jellyfin for Kodi") auth += "Client=%s, " % quote(
auth += "Device=%s, " % self.config.data.get( self.config.data.get("app.name", "Jellyfin for Kodi")
"app.device_name", "Unknown Device"
) )
auth += "DeviceId=%s, " % self.config.data.get( auth += "Device=%s, " % quote(
"app.device_id", "Unknown Device id" self.config.data.get("app.device_name", "Unknown Device")
) )
auth += "Version=%s" % self.config.data.get("app.version", "0.0.0") auth += "DeviceId=%s, " % quote(
self.config.data.get("app.device_id", "Unknown Device id")
)
auth += "Version=%s" % quote(self.config.data.get("app.version", "0.0.0"))
data["headers"].update({"x-emby-authorization": auth}) data["headers"].update({"x-emby-authorization": auth})
if self.config.data.get("auth.token") and self.config.data.get("auth.user_id"): if self.config.data.get("auth.token") and self.config.data.get("auth.user_id"):
auth += ", UserId=%s" % self.config.data.get("auth.user_id") auth += ", UserId=%s" % quote(self.config.data.get("auth.user_id"))
data["headers"].update( data["headers"].update(
{ {
"x-emby-authorization": auth, "x-emby-authorization": auth,