diff --git a/package-lock.json b/package-lock.json index 19387635..21957d0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6771,9 +6771,12 @@ "dev": true }, "fast-xml-parser": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.16.0.tgz", - "integrity": "sha512-U+bpScacfgnfNfIKlWHDu4u6rtOaCyxhblOLJ8sZPkhsjgGqdZmVPBhdOyvdMGCDt8CsAv+cssOP3NzQptNt2w==" + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.4.tgz", + "integrity": "sha512-fbfMDvgBNIdDJLdLOwacjFAPYt67tr31H9ZhWSm45CDAxvd0I6WTlSOUo7K2P/K5sA5JgMKG64PI3DMcaFdWpQ==", + "requires": { + "strnum": "^1.0.5" + } }, "fastq": { "version": "1.6.0", @@ -17006,6 +17009,11 @@ "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", "dev": true }, + "strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" + }, "stubs": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", diff --git a/package.json b/package.json index a107545b..fb9bed04 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "abab": "^2.0.3", "debug": "^4.1.1", "eventemitter3": "^4.0.0", - "fast-xml-parser": "^3.16.0", + "fast-xml-parser": "^4.2.4", "file-type": "^10.11.0", "follow-redirects": "^1.10.0", "isutf8": "^2.1.0", diff --git a/src/lib/request/helpers/data.ts b/src/lib/request/helpers/data.ts index 6315ecd5..94dacaa6 100644 --- a/src/lib/request/helpers/data.ts +++ b/src/lib/request/helpers/data.ts @@ -18,7 +18,7 @@ import { isURLSearchParams, isObject, isStream, isFormData, isArrayBuffer, isFil import { getVersion, uniqueId } from './../../utils'; import { FsRequestOptions, FsResponse } from './../types'; import { set } from './headers'; -import * as parser from 'fast-xml-parser'; +import { XMLParser, XMLValidator } from 'fast-xml-parser'; import Debug from 'debug'; const debug = Debug('fs:request:data'); @@ -99,11 +99,14 @@ export const parseResponse = async (response: FsResponse): Promise = data = bufferToString(response.data); } - if (parser.validate(data) === true) { - response.data = parser.parse(data, { + if (XMLValidator.validate(data) === true) { + const parser = new XMLParser({ + ignoreDeclaration: true, ignoreAttributes : true, trimValues: true, }); + + response.data = parser.parse(data); } }