From 16d092a8a715463f7884f53341c064accd4da952 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 15 Jan 2021 12:17:50 +0000 Subject: [PATCH 1/5] Fixed encoding issue --- Emby.Dlna/PlayTo/TransportCommands.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.cs index 0865968ad1..42027b5af7 100644 --- a/Emby.Dlna/PlayTo/TransportCommands.cs +++ b/Emby.Dlna/PlayTo/TransportCommands.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Security; using System.Xml.Linq; using Emby.Dlna.Common; using Emby.Dlna.Ssdp; @@ -175,12 +176,12 @@ namespace Emby.Dlna.PlayTo if (state != null) { var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ?? - (state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value); + (state.AllowedValues.Count > 0 ? state.AllowedValues[0] : SecurityElement.Escape(value)); return string.Format(CultureInfo.InvariantCulture, "<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}", argument.Name, state.DataType ?? "string", sendValue); } - return string.Format(CultureInfo.InvariantCulture, "<{0}>{1}", argument.Name, value); + return string.Format(CultureInfo.InvariantCulture, "<{0}>{1}", argument.Name, SecurityElement.Escape(value)); } } } From 620648fe81cd924c906326ea7afa236f937ff844 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 15 Jan 2021 18:55:52 +0000 Subject: [PATCH 2/5] Fixed for no data. --- Emby.Dlna/Didl/DidlBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index abaf522bca..02bfa6053e 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -113,6 +113,8 @@ namespace Emby.Dlna.Didl writer.WriteFullEndElement(); // writer.WriteEndDocument(); + + writer.Flush(); } return builder.ToString(); From 13012bfa273a98d06771bc11aeca1d62f9f23307 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sat, 16 Jan 2021 20:08:41 +0000 Subject: [PATCH 3/5] Fix bug in GetItemId --- Emby.Dlna/PlayTo/PlayToController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index 311fae2400..315be1e8be 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -896,16 +896,16 @@ namespace Emby.Dlna.PlayTo var parts = url.Split('/'); - for (var i = 0; i < parts.Length; i++) + for (var i = 0; i < parts.Length - 1; i++) { var part = parts[i]; if (string.Equals(part, "audio", StringComparison.OrdinalIgnoreCase) || string.Equals(part, "videos", StringComparison.OrdinalIgnoreCase)) { - if (parts.Length > i + 1) + if (Guid.TryParse(parts[i + 1], out var result)) { - return Guid.Parse(parts[i + 1]); + return result; } } } From 828a9b7c75bbe79c8591c785745851e824589d11 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 17 Jan 2021 23:30:56 +0000 Subject: [PATCH 4/5] rollback --- Emby.Dlna/PlayTo/TransportCommands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.cs index 42027b5af7..3cf4b810d3 100644 --- a/Emby.Dlna/PlayTo/TransportCommands.cs +++ b/Emby.Dlna/PlayTo/TransportCommands.cs @@ -176,12 +176,12 @@ namespace Emby.Dlna.PlayTo if (state != null) { var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ?? - (state.AllowedValues.Count > 0 ? state.AllowedValues[0] : SecurityElement.Escape(value)); + (state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value); return string.Format(CultureInfo.InvariantCulture, "<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}", argument.Name, state.DataType ?? "string", sendValue); } - return string.Format(CultureInfo.InvariantCulture, "<{0}>{1}", argument.Name, SecurityElement.Escape(value)); + return string.Format(CultureInfo.InvariantCulture, "<{0}>{1}", argument.Name, value); } } } From e81b7c8f4f054aaf5c1f25ea9c9d6986fbd501c3 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Mon, 18 Jan 2021 12:17:18 +0000 Subject: [PATCH 5/5] reverted --- Emby.Dlna/Didl/DidlBuilder.cs | 3 +-- Emby.Dlna/PlayTo/TransportCommands.cs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 02bfa6053e..8b50d47fbd 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -96,6 +96,7 @@ namespace Emby.Dlna.Didl using (StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8)) { + // If this using are changed to single lines, then write.Flush needs to be appended before the return. using (var writer = XmlWriter.Create(builder, settings)) { // writer.WriteStartDocument(); @@ -113,8 +114,6 @@ namespace Emby.Dlna.Didl writer.WriteFullEndElement(); // writer.WriteEndDocument(); - - writer.Flush(); } return builder.ToString(); diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.cs index 3cf4b810d3..0865968ad1 100644 --- a/Emby.Dlna/PlayTo/TransportCommands.cs +++ b/Emby.Dlna/PlayTo/TransportCommands.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Security; using System.Xml.Linq; using Emby.Dlna.Common; using Emby.Dlna.Ssdp;