From 65623f20742d1a1b21437873c270b228e35508a0 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Sat, 31 Aug 2024 19:16:16 +0100 Subject: [PATCH] Escape XML instead of CDATA. Samsung TVs only understand escapes, but not CDATA. --- .../control/browse/response.tmpl.xml | 6 +----- crates/upnp-serve/src/services/content_directory.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/upnp-serve/src/resources/templates/content_directory/control/browse/response.tmpl.xml b/crates/upnp-serve/src/resources/templates/content_directory/control/browse/response.tmpl.xml index 09bb4de..6527db0 100644 --- a/crates/upnp-serve/src/resources/templates/content_directory/control/browse/response.tmpl.xml +++ b/crates/upnp-serve/src/resources/templates/content_directory/control/browse/response.tmpl.xml @@ -2,11 +2,7 @@ - - {items} -]]> + {items_encoded} {number_returned} {total_matches} {update_id} diff --git a/crates/upnp-serve/src/services/content_directory.rs b/crates/upnp-serve/src/services/content_directory.rs index b04e624..262dbef 100644 --- a/crates/upnp-serve/src/services/content_directory.rs +++ b/crates/upnp-serve/src/services/content_directory.rs @@ -135,11 +135,21 @@ pub mod browse { } fn render_response(envelope: &Envelope<'_>) -> String { + let items_encoded = format!( + r#" + {items} + "#, + items = envelope.items + ); + let items_encoded = quick_xml::escape::escape(items_encoded.as_ref()); + format!( include_str!( "../resources/templates/content_directory/control/browse/response.tmpl.xml" ), - items = envelope.items, + items_encoded = items_encoded, number_returned = envelope.number_returned, total_matches = envelope.total_matches, update_id = envelope.update_id