Kodi Community Forum
UPNP server - bad request and XML parsing - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: UPNP server - bad request and XML parsing (/showthread.php?tid=358054)



UPNP server - bad request and XML parsing - itsacoaster - 2020-10-29

Hello there, I'm tinkering around with turning a Raspberry Pi 4 into a media server to access on my devices, so I'm messing around with Kodi for now for the easy library organization.

The first thing I tried was using Kodi as a UPnP/DLNA server. Yes I know, there are better ways to do it than this, but it's supported by a great many clients out there.

By the way, the report below applies to running Kodi on Windows, but the same behavior occurs on LibreElec.

I noticed when browsing through TV Show Titles that when I try to enter a Season folder to choose a title (Video Library -> TV Shows -> Title -> ShowName -> Season#), the list of episodes never appears. This happens on two different DLNA clients (VLC iOS and Roku Media Player) - VLC on Windows works fine.

So I was digging into the debug logs and saw that it reported:
HTTP/1.1 500 Bad Request: Error Parsing XML Body

Okay, so what does that XML request look like?  I pulled up Wireshark to see:
Code:
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
    <u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<ObjectID>videodb://tvshows/titles/1/1/?tvshowid=1&xsp=%7b%22order%22%3a%7b%22direction%22%3a%22ascending%22%2c%22ignorefolders%22%3a0%2c%22method%22%3a%22sorttitle%22%7d%2c%22type%22%3a%22tvshows%22%7d</ObjectID><BrowseFlag>BrowseDirectChildren</BrowseFlag><Filter>id,dc:title,dc:description,dc:date,upnp:longDescription,upnp:artist,upnp:album,upnp:albumArtURI,upnp:rating,upnp:scheduledStartTime,upnp:genre,res,res@duration,res@bitrate,res@size,res@protocolInfo,res@resolution,container@childCount,upnp:originalTrackNumber,res@pv:subtitleFileType,res@pv:subtitleFileUri</Filter><StartingIndex>0</StartingIndex><RequestedCount>10</RequestedCount><SortCriteria></SortCriteria>      </u:Browse>
   </s:Body>
</s:Envelope>


You'll notice something very subtle. In the ObjectID tag you see:
videodb://tvshows/titles/1/1/?tvshowid=1&xsp=...

Since this & is not escaped to look like &amp, it fails the XML parser.  As I understand it, this is the technically proper behavior, but given that two out of three clients are not escaping the ampersand, surely there are some parsers on UPnP servers that accept it.

I see that the XML parsing is handled by Platinum UPnP SDK which runs on Neptune HTTP server, so I'm guessing this is out of Kodi's control... is it?  I thought I might post and ask before complaining to the client software developers telling them they're pushing out invalid XML.
Anyway thanks for taking a look.

I heard you folks like log files: https://paste.kodi.tv/evudixidid.kodi

P.S.: This is NOT the end of the world because I can still browse the file structure over UPnP, thank goodness I spent so much time organizing my library. :)