Use AuthorizationHeaderBuilder to encode device name send to web client (#466)

This makes sure the SDK and webui use an identical name
This commit is contained in:
Niels van Velzen authored and GitHub committed 2021-07-13 16:27:52 +02:00
1 parent 77e1bceb74
commit c530206ba9
1 file changed
+2 -4
@@ -34,6 +34,7 @@ import org.jellyfin.mobile.utils.runOnUiThread
import org.jellyfin.mobile.webapp.RemotePlayerService
import org.jellyfin.mobile.webapp.RemoteVolumeProvider
import org.jellyfin.mobile.webapp.WebappFunctionChannel
import org.jellyfin.sdk.api.client.util.AuthorizationHeaderBuilder
import org.jellyfin.sdk.model.ClientInfo
import org.jellyfin.sdk.model.DeviceInfo
import org.json.JSONArray
@@ -60,10 +61,7 @@ class NativeInterface(private val fragment: WebViewFragment) : KoinComponent {
// normalize the name by removing special characters
// and making sure it's at least 1 character long
// otherwise the webui will fail to send it to the server
val name = deviceInfo.name
.replace("[^\\x20-\\x7E]".toRegex(), "")
.trim()
.padStart(1)
val name = AuthorizationHeaderBuilder.encodeParameterValue(deviceInfo.name).padStart(1)
put("deviceName", name)
put("appName", clientInfo.name)
put("appVersion", clientInfo.version)