Escape XML instead of CDATA. Samsung TVs only understand escapes, but not CDATA.

This commit is contained in:
Igor Katson 2024-08-31 19:16:16 +01:00
parent 79a8451519
commit 65623f2074
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 12 additions and 6 deletions

View file

@ -2,11 +2,7 @@
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result><![CDATA[<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
{items}
</DIDL-Lite>]]></Result>
<Result>{items_encoded}</Result>
<NumberReturned>{number_returned}</NumberReturned>
<TotalMatches>{total_matches}</TotalMatches>
<UpdateID>{update_id}</UpdateID>

View file

@ -135,11 +135,21 @@ pub mod browse {
}
fn render_response(envelope: &Envelope<'_>) -> String {
let items_encoded = format!(
r#"<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
{items}
</DIDL-Lite>"#,
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