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

Release version v1.13.1 #242

Merged
merged 5 commits into from
Jul 22, 2024
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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## [v1.13.1] - 2024-07-22

### Fixed

- Fixed TypeError occurring for files with non UTF-8 encoding while parsing.

## [v1.13.0] - 2024-07-10

### Chore
Expand Down Expand Up @@ -118,7 +124,9 @@ Newer releases follow the [Keep a Changelog](https://keepachangelog.com) format.
- Stable release
- Removed libxmljs from package.json

[Unreleased]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.13.0...HEAD
[Unreleased]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.13.1...HEAD

[v1.13.1]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.13.0...v1.13.1

[v1.13.0]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.12.3...v1.13.0

Expand Down
9 changes: 8 additions & 1 deletion lib/XMLParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ class XMLParser {
if (!xmlDocumentContent) {
return '';
}
return fastXMLParser.parse(fixComments(xmlDocumentContent), optionsForFastXMLParser);

try {
return fastXMLParser.parse(fixComments(xmlDocumentContent), optionsForFastXMLParser);
}
catch (_e) {
// ignore errors while parsing data
return '';
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@postman/wsdl-to-postman",
"version": "1.13.0",
"version": "1.13.1",
"description": "Convert a given WSDL specification (1.1) to Postman Collection",
"main": "index.js",
"bin": {
Expand Down
37 changes: 37 additions & 0 deletions test/unit/XMLParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,40 @@ describe('XMLparser parseObjectToXML', function () {
});

});

describe('XMLParser safeParseToObject', function () {
const xmlParser = new XMLParser({});

it('should return an empty string when input is an empty file', function () {
let parsed = xmlParser.safeParseToObject('');
expect(parsed).to.equal('');
});

it('should return an empty string when input is null', function () {
let parsed = xmlParser.safeParseToObject(null);
expect(parsed).to.equal('');
});

it('should return an empty string when input is undefined', function () {
let parsed = xmlParser.safeParseToObject(undefined);
expect(parsed).to.equal('');
});

it('should return an object when input is valid XML', function () {
const validXML = `<note>
<to>User</to>
<from>Library</from>
<heading>Reminder</heading>
<body>Hello</body>
</note>`;
let parsed = xmlParser.safeParseToObject(validXML);
expect(parsed).to.be.an('object');
expect(parsed).to.have.own.property('note');
});

it('should return an empty string when fast-zml-parser fails to parse data', function () {
const invalidXML = '€¯!¢s1≤TO¿˛•LH¥Ò‘⁄∞E»ËòŶTìæv◊ ';
let parsed = xmlParser.safeParseToObject(invalidXML);
expect(parsed).to.equal('');
});
});
Loading