Error with Sonos-Binding and Ampersand (&) in Favorites

Hi there,

I am using a Sonos Speaker with Openhab. I have added an Music station from Amazon Music and want to use it with Openhab. The command I am using for this is:

sendCommand(Sonos_Favorite,"Entspannte Rock-Klassiker & Oldies")
sendCommand(Sonos_Volume,20)   
sendCommand(Sonos_Controller,PLAY)

It works without problems so far, however in the openhab.log I get the error

2017-07-14 22:31:29.958 [ERROR] [inding.sonos.internal.SonosXMLParser] - Could not parse MetaData from string '<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="100c206ccatalog%2fstations%......%2f%23chunk-....." parentID="10012064catalog%2fstations%2frefinements%2fgenres%2fa3d0cc3b-368f-465e-b995-fasdafs%2f%23prime_stations" restricted="true"><dc:title>Entspannte Rock-Klassiker & Oldies</dc:title><upnp:class>object.item.audioItem.audioBroadcast</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON51363_X_#Svc533463-0-Token</desc></item></DIDL-Lite>'

and in the openhab console I get the error

[Fatal Error] :1:481: Auf "&" in der Entityreferenz muss umgehend der Entityname folgen.

or in english:
The entity name must immediately follow the '&' in the entity reference.

I think this is because of the ampersand. It is unescaped in the xml. But if I try to specify the favorite with

sendCommand(Sonos_Favorite,"Entspannte Rock-Klassiker &amp; Oldies")

it will not be found. Is there any way how to deal with this? Unfortunately I cannot rename the favorite in the Sonos app.

I agree with your conclusion about the ampersand.

A quick search didn’t find any open tickets about this. You should probably file a defect. It’d be good to include a debug log if possible.

Try to replace & by %26 ?

Or “Entspannte Rock-Klassiker &amp;amp; Oldies

I have tried several other encodings. They all generate an error that the favorite cannot be found:

Favorite 'Entspannte Rock-Klassiker &amp;amp; Oldies' not found
Favorite 'Entspannte Rock-Klassiker %26 Oldies' not found
Favorite 'Entspannte Rock-Klassiker &#38; Oldies' not found

The only working one, is the one with the &. But it generates lots of errors in the console. I am filing a bug report for this.

A fix is included in snapshot 1034. Please let me know if this is ok.