Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
schwark opened this issue Sep 29, 2022 · 0 comments

Comments

@schwark
Copy link

schwark commented Sep 29, 2022

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant