From 7941eb4a9c566250a8a450e1c4bf14099542dd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Fri, 12 Sep 2025 02:52:30 +0200 Subject: [PATCH 1/2] Properly encode device name and related parameters --- jellyfin_kodi/client.py | 2 -- jellyfin_kodi/jellyfin/api.py | 9 +++++---- jellyfin_kodi/jellyfin/http.py | 17 ++++++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/jellyfin_kodi/client.py b/jellyfin_kodi/client.py index cf8c3315..0d6f5a2e 100644 --- a/jellyfin_kodi/client.py +++ b/jellyfin_kodi/client.py @@ -63,8 +63,6 @@ def get_device_name(): device_name = xbmc.getInfoLabel("System.FriendlyName") else: device_name = settings("deviceName") - device_name = device_name.replace('"', "_") - device_name = device_name.replace("/", "_") return device_name diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index 15b8c78e..fd25e547 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -2,6 +2,7 @@ from __future__ import division, absolute_import, print_function, unicode_literals import json +from urllib.parse import quote import requests @@ -406,10 +407,10 @@ class API(object): def get_default_headers(self): auth = "MediaBrowser " - auth += "Client=%s, " % self.config.data["app.name"] - auth += "Device=%s, " % self.config.data["app.device_name"] - auth += "DeviceId=%s, " % self.config.data["app.device_id"] - auth += "Version=%s" % self.config.data["app.version"] + auth += "Client=%s, " % quote(self.config.data["app.name"]) + auth += "Device=%s, " % quote(self.config.data["app.device_name"]) + auth += "DeviceId=%s, " % quote(self.config.data["app.device_id"]) + auth += "Version=%s" % quote(self.config.data["app.version"]) return { "Accept": "application/json", diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index bf6d103e..b7eae435 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -4,6 +4,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# import time +from urllib.parse import quote import requests @@ -247,20 +248,22 @@ class HTTP(object): def _authorization(self, data): auth = "MediaBrowser " - auth += "Client=%s, " % self.config.data.get("app.name", "Jellyfin for Kodi") - auth += "Device=%s, " % self.config.data.get( - "app.device_name", "Unknown Device" + auth += "Client=%s, " % quote( + self.config.data.get("app.name", "Jellyfin for Kodi") ) - auth += "DeviceId=%s, " % self.config.data.get( - "app.device_id", "Unknown Device id" + auth += "Device=%s, " % quote( + 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}) 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( { "x-emby-authorization": auth, From beaa66e739e6812c11dc181c2c368e0b88774a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Fri, 12 Sep 2025 21:30:43 +0200 Subject: [PATCH 2/2] Also quote / --- jellyfin_kodi/jellyfin/api.py | 8 ++++---- jellyfin_kodi/jellyfin/http.py | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index fd25e547..fa80a19d 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -407,10 +407,10 @@ class API(object): def get_default_headers(self): auth = "MediaBrowser " - auth += "Client=%s, " % quote(self.config.data["app.name"]) - auth += "Device=%s, " % quote(self.config.data["app.device_name"]) - auth += "DeviceId=%s, " % quote(self.config.data["app.device_id"]) - auth += "Version=%s" % quote(self.config.data["app.version"]) + auth += "Client=%s, " % quote(self.config.data["app.name"], safe="") + auth += "Device=%s, " % quote(self.config.data["app.device_name"], safe="") + auth += "DeviceId=%s, " % quote(self.config.data["app.device_id"], safe="") + auth += "Version=%s" % quote(self.config.data["app.version"], safe="") return { "Accept": "application/json", diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index b7eae435..e6eaa897 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -249,21 +249,23 @@ class HTTP(object): auth = "MediaBrowser " auth += "Client=%s, " % quote( - self.config.data.get("app.name", "Jellyfin for Kodi") + self.config.data.get("app.name", "Jellyfin for Kodi"), safe="" ) auth += "Device=%s, " % quote( - self.config.data.get("app.device_name", "Unknown Device") + self.config.data.get("app.device_name", "Unknown Device"), safe="" ) auth += "DeviceId=%s, " % quote( - self.config.data.get("app.device_id", "Unknown Device id") + self.config.data.get("app.device_id", "Unknown Device id"), safe="" + ) + auth += "Version=%s" % quote( + self.config.data.get("app.version", "0.0.0"), safe="" ) - auth += "Version=%s" % quote(self.config.data.get("app.version", "0.0.0")) data["headers"].update({"x-emby-authorization": auth}) if self.config.data.get("auth.token") and self.config.data.get("auth.user_id"): - auth += ", UserId=%s" % quote(self.config.data.get("auth.user_id")) + auth += ", UserId=%s" % quote(self.config.data.get("auth.user_id"), safe="") data["headers"].update( { "x-emby-authorization": auth,