diff --git a/lib/helpers.js b/lib/helpers.js index 740b69b..ed0e23b 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -328,4 +328,15 @@ Helpers.ParseXml = async function (input) { }) } +/** + * Sanitizes Device Description XML async + * @param {String} input The XML to be sanitized + * @return {Promise} + */ +Helpers.SanitizeDeviceDescriptionXml = async function (input) { + // This is to fix malformed xml in description see https://github.com/bencevans/node-sonos/issues/465 + debug('Helpers.SanitizeDeviceDescriptionXml %j', input) + return input.replace(/#([\w]+)#/gm, '') +} + module.exports = Helpers diff --git a/lib/sonos.js b/lib/sonos.js index f812c50..98970a9 100644 --- a/lib/sonos.js +++ b/lib/sonos.js @@ -603,6 +603,7 @@ Sonos.prototype.deviceDescription = async function () { debug('Sonos.deviceDescription()') return request(`http://${this.host}:${this.port}/xml/device_description.xml`) .then(response => response.data) + .then(Helpers.SanitizeDeviceDescriptionXml) .then(Helpers.ParseXml) .then(result => { return result.root.device