Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to fast-xml-parser 4.1.3 due to security reasons #35

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
'use strict';
const parser = require('fast-xml-parser');
const {XMLParser, XMLValidator} = require('fast-xml-parser');

const isSvg = input => {
if (input === undefined || input === null) {
return false;
}

// TODO: Remove the `.replace` call when using `fast-xml-parser@4` which has fixed the bug.
input = input.toString().trim().replace(/\n/g, ' ');
input = input.toString().trim();

if (input.length === 0) {
return false;
}

// Has to be `!==` as it can also return an object with error info.
if (parser.validate(input) !== true) {
if (XMLValidator.validate(input) !== true) {
return false;
}

let jsonObject;
const parser = new XMLParser();

try {
jsonObject = parser.parse(input);
} catch (_) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"buffer"
],
"dependencies": {
"fast-xml-parser": "^3.19.0"
"fast-xml-parser": "^4.1.3"
},
"devDependencies": {
"@types/node": "^11.13.0",
Expand Down