Skip to content

Commit

Permalink
Merge pull request #740 from postmanlabs/release/v1.10.0
Browse files Browse the repository at this point in the history
Release version v1.10.0
  • Loading branch information
VShingala authored May 2, 2024
2 parents 5386053 + ea72583 commit 4f83936
Show file tree
Hide file tree
Showing 61 changed files with 1,247 additions and 1,196 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

## [v1.10.0] - 2024-05-02

### Fixed

- Fix `+` char being encoded in query params of multiple languages.
- Fix special characters not being escaped in multiple languages.

## [v1.9.0] - 2024-01-18

### Fixed
Expand Down Expand Up @@ -146,7 +153,9 @@ v1.0.0 (May 29, 2020)
- Add ES6 syntax support for NodeJS Request, NodeJS Native and NodeJS Unirest
- Fix snippet generation for powershell and jquery, where form data params had no type field

[Unreleased]: https://github.com/postmanlabs/postman-code-generators/compare/v1.9.0...HEAD
[Unreleased]: https://github.com/postmanlabs/postman-code-generators/compare/v1.10.0...HEAD

[v1.10.0]: https://github.com/postmanlabs/postman-code-generators/compare/v1.9.0...v1.10.0

[v1.9.0]: https://github.com/postmanlabs/postman-code-generators/compare/v1.8.0...v1.9.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,11 @@
],
"body": {},
"url": {
"raw": "https://mockbin.org/request",
"raw": "https://postman-echo.com/request",
"protocol": "https",
"host": [
"mockbin",
"org"
"postman-echo",
"com"
],
"path": [
"request"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1098,13 +1098,11 @@
"raw": ""
},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/link",
"raw": "https://postman-echo.com/link",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"link"
Expand All @@ -1128,13 +1126,11 @@
"raw": ""
},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/unlick",
"raw": "https://postman-echo.com/unlick",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"unlick"
Expand All @@ -1158,13 +1154,11 @@
"raw": ""
},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/lock",
"raw": "https://postman-echo.com/lock",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"lock"
Expand All @@ -1180,13 +1174,11 @@
"header": [],
"body": {},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/unlock",
"raw": "https://postman-echo.com/unlock",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"unlock"
Expand All @@ -1210,13 +1202,11 @@
"raw": ""
},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/profind",
"raw": "https://postman-echo.com/profind",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"profind"
Expand All @@ -1240,13 +1230,11 @@
"raw": ""
},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/view",
"raw": "https://postman-echo.com/view",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"view"
Expand All @@ -1262,13 +1250,11 @@
"header": [],
"body": {},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/view",
"raw": "https://postman-echo.com/view",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"view"
Expand All @@ -1284,13 +1270,11 @@
"header": [],
"body": {},
"url": {
"raw": "https://9c76407d-5b8d-4b22-99fb-8c47a85d9848.mock.pstmn.io",
"raw": "https://postman-echo.com",
"protocol": "https",
"host": [
"9c76407d-5b8d-4b22-99fb-8c47a85d9848",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
]
}
},
Expand Down Expand Up @@ -1378,7 +1362,7 @@
}
],
"cookie": [],
"body": "{\n \"args\": {},\n \"data\": \"Curabitur auctor, elit nec pulvinar porttitor, ex augue condimentum enim, eget suscipit urna felis quis neque.\\nSuspendisse sit amet luctus massa, nec venenatis mi. Suspendisse tincidunt massa at nibh efficitur fringilla. Nam quis congue mi. Etiam volutpat.\",\n \"files\": {},\n \"form\": {},\n \"headers\": {\n \"host\": \"postman-echo.com\",\n \"content-length\": \"256\",\n \"accept\": \"*/*\",\n \"accept-encoding\": \"gzip, deflate\",\n \"content-type\": \"text/plain\",\n \"cookie\": \"sails.sid=s%3A1wOi4AdoZEbqBjGi6oSUC5Vlfje8wJvs.DHQfRLXfIBvZ%2Bv0KhLAThMDz%2FXvxh9gyxWYa0u1EZOU\",\n \"user-agent\": \"PostmanRuntime/7.1.1\",\n \"x-forwarded-port\": \"443\",\n \"x-forwarded-proto\": \"https\"\n },\n \"json\": null,\n \"url\": \"https://9c76407d-5b8d-4b22-99fb-8c47a85d9848.mock.pstmn.io\"\n}"
"body": "{\n \"args\": {},\n \"data\": \"Curabitur auctor, elit nec pulvinar porttitor, ex augue condimentum enim, eget suscipit urna felis quis neque.\\nSuspendisse sit amet luctus massa, nec venenatis mi. Suspendisse tincidunt massa at nibh efficitur fringilla. Nam quis congue mi. Etiam volutpat.\",\n \"files\": {},\n \"form\": {},\n \"headers\": {\n \"host\": \"postman-echo.com\",\n \"content-length\": \"256\",\n \"accept\": \"*/*\",\n \"accept-encoding\": \"gzip, deflate\",\n \"content-type\": \"text/plain\",\n \"cookie\": \"sails.sid=s%3A1wOi4AdoZEbqBjGi6oSUC5Vlfje8wJvs.DHQfRLXfIBvZ%2Bv0KhLAThMDz%2FXvxh9gyxWYa0u1EZOU\",\n \"user-agent\": \"PostmanRuntime/7.1.1\",\n \"x-forwarded-port\": \"443\",\n \"x-forwarded-proto\": \"https\"\n },\n \"json\": null,\n \"url\": \"https://postman-echo.com\"\n}"
}
]
},
Expand All @@ -1389,13 +1373,11 @@
"header": [],
"body": {},
"url": {
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/copy",
"raw": "https://postman-echo.com/copy",
"protocol": "https",
"host": [
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
"mock",
"pstmn",
"io"
"postman-echo",
"com"
],
"path": [
"copy"
Expand All @@ -1411,11 +1393,11 @@
"header": [],
"body": {},
"url": {
"raw": "https://mockbin.org/request",
"raw": "https://postman-echo.com/request",
"protocol": "https",
"host": [
"mockbin",
"org"
"postman-echo",
"com"
],
"path": [
"request"
Expand Down Expand Up @@ -1527,14 +1509,14 @@
{
"expires": "Thu Mar 14 2019 13:12:10 GMT+0530 (IST)",
"httpOnly": true,
"domain": "mockbin.org",
"domain": "postman-echo.com",
"path": "/",
"secure": false,
"value": "dfb94a3e1f3f8a9956138e4896847caf21521013330",
"key": "__cfduid"
}
],
"body": "{\n \"startedDateTime\": \"2018-03-14T09:06:37.443Z\",\n \"clientIPAddress\": \"106.51.70.154\",\n \"method\": \"COPY\",\n \"url\": \"https://mockbin.org/request\",\n \"httpVersion\": \"HTTP/1.1\",\n \"cookies\": {\n \"__cfduid\": \"dfb94a3e1f3f8a9956138e4896847caf21521013330\"\n },\n \"headers\": {\n \"host\": \"mockbin.org\",\n \"connection\": \"close\",\n \"accept-encoding\": \"gzip\",\n \"x-forwarded-for\": \"106.51.70.154, 172.68.255.127\",\n \"cf-ray\": \"3fb595d5facaa302-HKG\",\n \"x-forwarded-proto\": \"http\",\n \"cf-visitor\": \"{\\\"scheme\\\":\\\"https\\\"}\",\n \"cache-control\": \"no-cache\",\n \"postman-token\": \"8d5b9832-75df-432f-90a3-284dacef0478\",\n \"user-agent\": \"PostmanRuntime/7.1.1\",\n \"accept\": \"*/*\",\n \"cookie\": \"__cfduid=dfb94a3e1f3f8a9956138e4896847caf21521013330\",\n \"cf-connecting-ip\": \"106.51.70.154\",\n \"x-request-id\": \"0e41473d-5130-4a6e-968d-b2a16cda3364\",\n \"x-forwarded-port\": \"80\",\n \"via\": \"1.1 vegur\",\n \"connect-time\": \"2\",\n \"x-request-start\": \"1521018397437\",\n \"total-route-time\": \"0\",\n \"content-length\": \"0\"\n },\n \"queryString\": {},\n \"postData\": {\n \"mimeType\": \"application/octet-stream\",\n \"text\": \"\",\n \"params\": []\n },\n \"headersSize\": 637,\n \"bodySize\": 0\n}"
"body": "{\n \"startedDateTime\": \"2018-03-14T09:06:37.443Z\",\n \"clientIPAddress\": \"106.51.70.154\",\n \"method\": \"COPY\",\n \"url\": \"https://postman-echo.com/request\",\n \"httpVersion\": \"HTTP/1.1\",\n \"cookies\": {\n \"__cfduid\": \"dfb94a3e1f3f8a9956138e4896847caf21521013330\"\n },\n \"headers\": {\n \"host\": \"postman-echo.com\",\n \"connection\": \"close\",\n \"accept-encoding\": \"gzip\",\n \"x-forwarded-for\": \"106.51.70.154, 172.68.255.127\",\n \"cf-ray\": \"3fb595d5facaa302-HKG\",\n \"x-forwarded-proto\": \"http\",\n \"cf-visitor\": \"{\\\"scheme\\\":\\\"https\\\"}\",\n \"cache-control\": \"no-cache\",\n \"postman-token\": \"8d5b9832-75df-432f-90a3-284dacef0478\",\n \"user-agent\": \"PostmanRuntime/7.1.1\",\n \"accept\": \"*/*\",\n \"cookie\": \"__cfduid=dfb94a3e1f3f8a9956138e4896847caf21521013330\",\n \"cf-connecting-ip\": \"106.51.70.154\",\n \"x-request-id\": \"0e41473d-5130-4a6e-968d-b2a16cda3364\",\n \"x-forwarded-port\": \"80\",\n \"via\": \"1.1 vegur\",\n \"connect-time\": \"2\",\n \"x-request-start\": \"1521018397437\",\n \"total-route-time\": \"0\",\n \"content-length\": \"0\"\n },\n \"queryString\": {},\n \"postData\": {\n \"mimeType\": \"application/octet-stream\",\n \"text\": \"\",\n \"params\": []\n },\n \"headersSize\": 637,\n \"bodySize\": 0\n}"
}
]
}
Expand Down
10 changes: 9 additions & 1 deletion codegens/curl/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ var self = module.exports = {
inputString = inputString.replace(/"/g, '\\"');
// Escape backslash if double quote was already escaped before call to sanitize
inputString = inputString.replace(/(?<!\\)\\\\"/g, '\\\\\\"');

// Escape special characters to preserve their literal meaning within double quotes
inputString = inputString
.replace(/`/g, '\\`')
.replace(/#/g, '\\#')
.replace(/\$/g, '\\$')
.replace(/!/g, '\\!');
}
else if (quoteType === '\'') {
// for curl escaping of single quotes inside single quotes involves changing of ' to '\''
Expand Down Expand Up @@ -207,7 +214,7 @@ var self = module.exports = {
},

/**
* Encode param except the following characters- [,{,},],%
* Encode param except the following characters- [,{,},],%,+
*
* @param {String} param
* @returns {String}
Expand All @@ -218,6 +225,7 @@ var self = module.exports = {
.replace(/%7B/g, '{')
.replace(/%5D/g, ']')
.replace(/%7D/g, '}')
.replace(/%2B/g, '+')
.replace(/%25/g, '%')
.replace(/'/g, '%27');
},
Expand Down
40 changes: 37 additions & 3 deletions codegens/curl/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,40 @@ describe('curl convert function', function () {
});
});

it('should escape special characters when quoteType is "double"', function () {
var request = new sdk.Request({
'method': 'POST',
'header': [],
'body': {
'mode': 'raw',
'raw': '{\r\n "hello": "$(whoami)"\r\n}',
'options': {
'raw': {
'language': 'json'
}
}
},
'url': {
'raw': 'https://postman-echo.com/post',
'protocol': 'https',
'host': [
'postman-echo',
'com'
],
'path': [
'post'
]
}
});
convert(request, { quoteType: 'double', lineContinuationCharacter: '^' }, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}

expect(snippet.includes('\\"hello\\": \\"\\$(whoami)\\"')).to.be.true; // eslint-disable-line
});
});

it('should longer option for body even if longFormat is disabled if @ character is present', function () {
let request = new sdk.Request({
'method': 'POST',
Expand Down Expand Up @@ -642,12 +676,12 @@ describe('curl convert function', function () {

it('should not encode unresolved query params and ' +
'encode every other query param, both present together', function () {
rawUrl = 'https://postman-echo.com/get?key1={{value}}&key2=\'a b c\'';
rawUrl = 'https://postman-echo.com/get?key1={{value}}&key2=\'a b+c\'';
urlObject = new sdk.Url(rawUrl);
outputUrlString = getUrlStringfromUrlObject(urlObject);
expect(outputUrlString).to.not.include('key1=%7B%7Bvalue%7B%7B');
expect(outputUrlString).to.not.include('key2=\'a b c\'');
expect(outputUrlString).to.equal('https://postman-echo.com/get?key1={{value}}&key2=%27a%20b%20c%27');
expect(outputUrlString).to.not.include('key2=\'a b+c\'');
expect(outputUrlString).to.equal('https://postman-echo.com/get?key1={{value}}&key2=%27a%20b+c%27');
});

it('should not encode query params that are already encoded', function () {
Expand Down
Loading

0 comments on commit 4f83936

Please sign in to comment.