Skip to content

Commit

Permalink
Merge pull request #242 from postmanlabs/release/v1.13.1
Browse files Browse the repository at this point in the history
Release version v1.13.1
  • Loading branch information
VShingala authored Jul 22, 2024
2 parents 2014d3a + 921f8fe commit 845f91c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
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('');
});
});

0 comments on commit 845f91c

Please sign in to comment.