Skip to content

Having unpredictable xml entity resolution when multiple levels of encoding #82

@schwark

Description

@schwark

Trying to parse the below xml - there are embedded xml elements as some of the values. Those embedded xml values are randomly encoded or decoded - sometimes partially encoded/decoded when you retrieve values... Running in ten times leads to ten different combinations of some entities decoded or encoded in the values almost unpredictably..

xmlres.root['e:propertyset']['e:property']['LastChange'] is being accessed.

The result should be an xml string. That xml string happens to have further encoded xml in some of its attributes. Those attributes are sometimes fully decoded (making the xml invalid) or sometimes partially decoded (still invalid).. What is worse, is that it is completely unpredictable what comes out..

abovexmlparsed['Event']['InstanceID']['CurrentTrackMetadata']['_attr']['val'] - should be accessible and valid xml.

xml2lua
1.5-2 (installed) - /opt/homebrew/lib/luarocks/rocks-5.4
Lua 5.4.4 Copyright (C) 1994-2022 Lua.org, PUC-Rio on MacOS M1-Pro arm64

<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"><e:property><Event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/"><InstanceID val="0"><TransportState val="PLAYING"/><CurrentPlayMode val="NORMAL"/><CurrentCrossfadeMode val="0"/><NumberOfTracks val="1"/><CurrentTrack val="1"/><CurrentSection val="0"/><CurrentTrackURI val="x-sonos-htastream:RINCON_XXXXXXXX01400:spdif"/><CurrentTrackDuration val=""/><CurrentTrackMetaData val="&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;-1&quot; parentID=&quot;-1&quot; restricted=&quot;true&quot;&gt;&lt;res protocolInfo=&quot;x-sonos-htastream:::*&quot;&gt;x-sonos-htastream:RINCON_XXXXXXX01400:spdif&lt;/res&gt;&lt;r:audioInputIcon&gt;&lt;/r:audioInputIcon&gt;&lt;r:streamInfo&gt;21&lt;/r:streamInfo&gt;&lt;dc:title&gt; &lt;/dc:title&gt;&lt;upnp:class&gt;object.item&lt;/upnp:class&gt;&lt;r:episodeNumber&gt;0&lt;/r:episodeNumber&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;"/><r:NextTrackURI val=""/><r:NextTrackMetaData val=""/><r:EnqueuedTransportURI val=""/><r:EnqueuedTransportURIMetaData val=""/><PlaybackStorageMedium val="NETWORK"/><AVTransportURI val="x-sonos-htastream:RINCON_XXXXXXXXX01400:spdif"/><AVTransportURIMetaData val="&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;spdif-input&quot; parentID=&quot;0&quot;restricted=&quot;false&quot;&gt;&lt;dc:title&gt;RINCON_949F3E67640701400&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.linein.homeTheater&lt;/upnp:class&gt;&lt;res protocolInfo=&quot;spdif&quot;&gt;x-sonos-htastream:RINCON_XXXXXXXX01400:spdif&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;"/><CurrentTransportActions val="Set, Play"/><r:CurrentValidPlayModes val=""/></InstanceID></Event></e:property></e:propertyset>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions