Skip to content

Commit 61a81a0

Browse files
committed
Update dependencies to their latest releases
1 parent ac703ae commit 61a81a0

6 files changed

+3581
-1675
lines changed

api/src/DeviceFactory.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
const xmlParser = require('fast-xml-parser');
3+
const { XMLParser } = require('fast-xml-parser');
4+
const xmlParser = new XMLParser({ignoreAttributes: false, removeNSPrefix: true, processEntities: false});
45
const MediaServer = require('./MediaServer');
56
const MediaRenderer = require('./MediaRenderer');
67
const deviceQuirks = require('./deviceQuirks');

api/src/MediaRenderer.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33
const Device = require("./Device");
4-
const xmlParser = require("fast-xml-parser");
4+
const { XMLParser } = require('fast-xml-parser');
5+
const xmlParser = new XMLParser({ignoreAttributes: false, removeNSPrefix: true, processEntities: false});
56
const axios = require('./axios');
67
const soapErrHandler = require('./soapErrHandler');
78

@@ -178,7 +179,7 @@ class MediaRenderer extends Device {
178179
})
179180
.catch(soapErrHandler)
180181
.then(response => {
181-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
182+
const data = xmlParser.parse(response.data);
182183
const info = data?.Envelope?.Body?.GetPositionInfoResponse;
183184
if (info == null) {
184185
throw new Error(`Unexpected response from AVTransport: ${response.data}`)
@@ -211,7 +212,7 @@ class MediaRenderer extends Device {
211212
})
212213
.catch(soapErrHandler)
213214
.then(response => {
214-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
215+
const data = xmlParser.parse(response.data);
215216
const info = data?.Envelope?.Body?.GetTransportInfoResponse;
216217
if (info == null) {
217218
throw new Error(`Unexpected response from AVTransport: ${response.data}`)
@@ -245,7 +246,7 @@ class MediaRenderer extends Device {
245246
})
246247
.catch(soapErrHandler)
247248
.then(response => {
248-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
249+
const data = xmlParser.parse(response.data);
249250
const info = data?.Envelope?.Body?.GetVolumeDBRangeResponse;
250251
if (info == null) {
251252
throw new Error(`Unexpected response from RenderingControl: ${response.data}`)
@@ -278,7 +279,7 @@ class MediaRenderer extends Device {
278279
})
279280
.catch(soapErrHandler)
280281
.then(response => {
281-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
282+
const data = xmlParser.parse(response.data);
282283
const info = data?.Envelope?.Body?.GetVolumeDBResponse?.CurrentVolumeDB || data?.Envelope?.Body?.GetVolumeDBResponse?.CurrentVolume;
283284
if (info == null) {
284285
throw new Error(`Unexpected response from RenderingControl: ${response.data}`)
@@ -311,7 +312,7 @@ class MediaRenderer extends Device {
311312
})
312313
.catch(soapErrHandler)
313314
.then(response => {
314-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
315+
const data = xmlParser.parse(response.data);
315316
const info = data?.Envelope?.Body?.GetVolumeResponse?.CurrentVolume;
316317
if (info == null) {
317318
throw new Error(`Unexpected response from RenderingControl: ${response.data}`)

api/src/MediaServer.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
const xmlParser = require("fast-xml-parser");
3+
const { XMLParser } = require('fast-xml-parser');
4+
const xmlParser = new XMLParser({ignoreAttributes: false, removeNSPrefix: true, processEntities: false});
5+
const xmlParserWithNs = new XMLParser({ignoreAttributes: false, removeNSPrefix: false, processEntities: false});
46
const Device = require("./Device");
57
const toArray = require("./toArray");
68
const axios = require('./axios');
@@ -43,10 +45,10 @@ class MediaServer extends Device {
4345
})
4446
.catch(soapErrHandler)
4547
.then((response) => {
46-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
48+
const data = xmlParser.parse(response.data);
4749
const browseResponse = data?.Envelope?.Body?.BrowseResponse;
4850
const didlResult = _.unescape(browseResponse?.Result);
49-
const result = xmlParser.parse(didlResult, {ignoreAttributes: false});
51+
const result = xmlParserWithNs.parse(didlResult);
5052
const container = toArray(result["DIDL-Lite"].container);
5153
container.push(...(toArray(result["DIDL-Lite"].item)));
5254
browseResponse.Result = container;
@@ -84,10 +86,10 @@ class MediaServer extends Device {
8486
})
8587
.catch(soapErrHandler)
8688
.then((response) => {
87-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
89+
const data = xmlParser.parse(response.data);
8890
const browseResponse = data?.Envelope?.Body?.BrowseResponse;
8991
const didlResult = _.unescape(browseResponse?.Result);
90-
const result = xmlParser.parse(didlResult, {ignoreAttributes: false});
92+
const result = xmlParserWithNs.parse(didlResult);
9193
return {
9294
object: result["DIDL-Lite"].container || result["DIDL-Lite"].item,
9395
xml: browseResponse?.Result
@@ -117,7 +119,7 @@ class MediaServer extends Device {
117119
})
118120
.catch(soapErrHandler)
119121
.then((response) => {
120-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
122+
const data = xmlParser.parse(response.data);
121123
return data?.Envelope?.Body?.GetSearchCapabilitiesResponse?.SearchCaps;
122124
});
123125
}
@@ -147,10 +149,10 @@ class MediaServer extends Device {
147149
})
148150
.catch(soapErrHandler)
149151
.then((response) => {
150-
const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true});
152+
const data = xmlParser.parse(response.data);
151153
const searchResponse = data?.Envelope?.Body?.SearchResponse;
152154
const didlResult = _.unescape(searchResponse?.Result);
153-
const result = xmlParser.parse(didlResult, {ignoreAttributes: false});
155+
const result = xmlParserWithNs.parse(didlResult);
154156
const container = toArray(result["DIDL-Lite"].container);
155157
container.push(...(toArray(result["DIDL-Lite"].item)));
156158
searchResponse.Result = container;

api/src/soapErrHandler.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict';
22

3-
const xmlParser = require("fast-xml-parser");
3+
const { XMLParser } = require('fast-xml-parser');
4+
const xmlParser = new XMLParser({ignoreAttributes: false, removeNSPrefix: true, processEntities: false});
45
const SoapError = require("./SoapError");
56
module.exports = function (err) {
67
const rawXml = err?.response?.data;
78
if (rawXml) {
8-
const data = xmlParser.parse(rawXml, {ignoreAttributes: false, ignoreNameSpace: true});
9+
const data = xmlParser.parse(rawXml);
910
if (data?.Envelope?.Body?.Fault?.detail?.UPnPError) {
1011
throw new SoapError(JSON.stringify(data?.Envelope?.Body?.Fault?.detail?.UPnPError));
1112
}

0 commit comments

Comments
 (0)