aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2025-10-27 15:43:19 -0400
committerBond_009 <bond.009@outlook.com>2025-10-27 15:43:19 -0400
commit232c0399e27b7d922362f543ec993e1208faef69 (patch)
tree5135614691a44b8f687f853bfcaf7bda55bf3a38
parentdbb015441fdbdeb0d29714ffd3f5b168e7081021 (diff)
Backport pull request #15164 from jellyfin/release-10.11.z
Fix XmlOutputFormatter Original-merge: 2b94bb54aa1669abc2e0975f1a089389bcc6052a Merged-by: crobibero <cody@robibe.ro> Backported-by: Bond_009 <bond.009@outlook.com>
-rw-r--r--Jellyfin.Api/Formatters/XmlOutputFormatter.cs25
1 files changed, 24 insertions, 1 deletions
diff --git a/Jellyfin.Api/Formatters/XmlOutputFormatter.cs b/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
index 8dbb91d0a..46256c09d 100644
--- a/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
+++ b/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
@@ -1,4 +1,8 @@
+using System;
using System.Net.Mime;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace Jellyfin.Api.Formatters;
@@ -6,7 +10,7 @@ namespace Jellyfin.Api.Formatters;
/// <summary>
/// Xml output formatter.
/// </summary>
-public sealed class XmlOutputFormatter : StringOutputFormatter
+public sealed class XmlOutputFormatter : TextOutputFormatter
{
/// <summary>
/// Initializes a new instance of the <see cref="XmlOutputFormatter"/> class.
@@ -15,5 +19,24 @@ public sealed class XmlOutputFormatter : StringOutputFormatter
{
SupportedMediaTypes.Clear();
SupportedMediaTypes.Add(MediaTypeNames.Text.Xml);
+
+ SupportedEncodings.Add(Encoding.UTF8);
+ SupportedEncodings.Add(Encoding.Unicode);
+ }
+
+ /// <inheritdoc />
+ public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
+ {
+ ArgumentNullException.ThrowIfNull(context);
+ ArgumentNullException.ThrowIfNull(selectedEncoding);
+
+ var valueAsString = context.Object?.ToString();
+ if (string.IsNullOrEmpty(valueAsString))
+ {
+ return;
+ }
+
+ var response = context.HttpContext.Response;
+ await response.WriteAsync(valueAsString, selectedEncoding).ConfigureAwait(false);
}
}