bencevans / node-sonos

🔈 Sonos Media Player Interface/Client
https://www.npmjs.com/package/sonos
MIT License
703 stars 147 forks source link

Sanitizing malformed device description XML #468

Closed pascalopitz closed 4 years ago

pascalopitz commented 4 years ago

Addresses malformed device XML, see #465

svrooij commented 4 years ago

Thanks @pascalopitz for your contribution!

My regular expressions are a bit rusty, but replace(/#([_\w]+)#/gm, '<!-- #$1# -->') will look for #...# where the dots can be any A-Z, a-z, 0-9 or _, which is then replaced by an XML comment, right?

I've tested the regular expression, and it seems that \w already matches a _. So the expression could be /#([\w]+)#/gm.

Could you add a comment in the helper referring to the original issue, because this seems a pretty strange thing if someone would look at the code. If you add the below comment.

// This is to fix malformed xml in description see https://github.com/bencevans/node-sonos/issues/465

And commit it with this message (the format matters):

fix: Malformed xml in device description

Fixed #465

I will accept the change immediately, and because of the commit message format it will recognize it as new code to be automatically released as a new patch version.

bencevans commented 4 years ago

:tada: This PR is included in version 1.13.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: