Skip to content

Commit f9bc785

Browse files
authored
Merge branch 'postmanlabs:develop' into fix/golang-ioutils
2 parents 105a622 + c9f0527 commit f9bc785

File tree

66 files changed

+1447
-1251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1447
-1251
lines changed

CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## [Unreleased]
44

5+
## [v1.10.1] - 2024-05-06
6+
7+
## [v1.10.0] - 2024-05-02
8+
9+
### Fixed
10+
11+
- Fix `+` char being encoded in query params of multiple languages.
12+
- Fix special characters not being escaped in multiple languages.
13+
14+
## [v1.9.0] - 2024-01-18
15+
516
### Fixed
617

718
- Fix for - [#10139](https://github.com/postmanlabs/postman-app-support/issues/10139) Modify Swift codegen to work with multipart/form-data format, used for video file upload
@@ -144,7 +155,13 @@ v1.0.0 (May 29, 2020)
144155
- Add ES6 syntax support for NodeJS Request, NodeJS Native and NodeJS Unirest
145156
- Fix snippet generation for powershell and jquery, where form data params had no type field
146157

147-
[Unreleased]: https://github.com/postmanlabs/postman-code-generators/compare/v1.8.0...HEAD
158+
[Unreleased]: https://github.com/postmanlabs/postman-code-generators/compare/v1.10.1...HEAD
159+
160+
[v1.10.1]: https://github.com/postmanlabs/postman-code-generators/compare/v1.10.0...v1.10.1
161+
162+
[v1.10.0]: https://github.com/postmanlabs/postman-code-generators/compare/v1.9.0...v1.10.0
163+
164+
[v1.9.0]: https://github.com/postmanlabs/postman-code-generators/compare/v1.8.0...v1.9.0
148165

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

codegens/csharp-httpclient/test/unit/fixtures/testcollection/collection.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@
648648
],
649649
"body": {},
650650
"url": {
651-
"raw": "https://mockbin.org/request",
651+
"raw": "https://postman-echo.com/request",
652652
"protocol": "https",
653653
"host": [
654-
"mockbin",
655-
"org"
654+
"postman-echo",
655+
"com"
656656
],
657657
"path": [
658658
"request"

codegens/csharp-restsharp/test/unit/fixtures/testcollection/collection.json

+33-51
Original file line numberDiff line numberDiff line change
@@ -1098,13 +1098,11 @@
10981098
"raw": ""
10991099
},
11001100
"url": {
1101-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/link",
1101+
"raw": "https://postman-echo.com/link",
11021102
"protocol": "https",
11031103
"host": [
1104-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1105-
"mock",
1106-
"pstmn",
1107-
"io"
1104+
"postman-echo",
1105+
"com"
11081106
],
11091107
"path": [
11101108
"link"
@@ -1128,13 +1126,11 @@
11281126
"raw": ""
11291127
},
11301128
"url": {
1131-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/unlick",
1129+
"raw": "https://postman-echo.com/unlick",
11321130
"protocol": "https",
11331131
"host": [
1134-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1135-
"mock",
1136-
"pstmn",
1137-
"io"
1132+
"postman-echo",
1133+
"com"
11381134
],
11391135
"path": [
11401136
"unlick"
@@ -1158,13 +1154,11 @@
11581154
"raw": ""
11591155
},
11601156
"url": {
1161-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/lock",
1157+
"raw": "https://postman-echo.com/lock",
11621158
"protocol": "https",
11631159
"host": [
1164-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1165-
"mock",
1166-
"pstmn",
1167-
"io"
1160+
"postman-echo",
1161+
"com"
11681162
],
11691163
"path": [
11701164
"lock"
@@ -1180,13 +1174,11 @@
11801174
"header": [],
11811175
"body": {},
11821176
"url": {
1183-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/unlock",
1177+
"raw": "https://postman-echo.com/unlock",
11841178
"protocol": "https",
11851179
"host": [
1186-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1187-
"mock",
1188-
"pstmn",
1189-
"io"
1180+
"postman-echo",
1181+
"com"
11901182
],
11911183
"path": [
11921184
"unlock"
@@ -1210,13 +1202,11 @@
12101202
"raw": ""
12111203
},
12121204
"url": {
1213-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/profind",
1205+
"raw": "https://postman-echo.com/profind",
12141206
"protocol": "https",
12151207
"host": [
1216-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1217-
"mock",
1218-
"pstmn",
1219-
"io"
1208+
"postman-echo",
1209+
"com"
12201210
],
12211211
"path": [
12221212
"profind"
@@ -1240,13 +1230,11 @@
12401230
"raw": ""
12411231
},
12421232
"url": {
1243-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/view",
1233+
"raw": "https://postman-echo.com/view",
12441234
"protocol": "https",
12451235
"host": [
1246-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1247-
"mock",
1248-
"pstmn",
1249-
"io"
1236+
"postman-echo",
1237+
"com"
12501238
],
12511239
"path": [
12521240
"view"
@@ -1262,13 +1250,11 @@
12621250
"header": [],
12631251
"body": {},
12641252
"url": {
1265-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/view",
1253+
"raw": "https://postman-echo.com/view",
12661254
"protocol": "https",
12671255
"host": [
1268-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1269-
"mock",
1270-
"pstmn",
1271-
"io"
1256+
"postman-echo",
1257+
"com"
12721258
],
12731259
"path": [
12741260
"view"
@@ -1284,13 +1270,11 @@
12841270
"header": [],
12851271
"body": {},
12861272
"url": {
1287-
"raw": "https://9c76407d-5b8d-4b22-99fb-8c47a85d9848.mock.pstmn.io",
1273+
"raw": "https://postman-echo.com",
12881274
"protocol": "https",
12891275
"host": [
1290-
"9c76407d-5b8d-4b22-99fb-8c47a85d9848",
1291-
"mock",
1292-
"pstmn",
1293-
"io"
1276+
"postman-echo",
1277+
"com"
12941278
]
12951279
}
12961280
},
@@ -1378,7 +1362,7 @@
13781362
}
13791363
],
13801364
"cookie": [],
1381-
"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}"
1365+
"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}"
13821366
}
13831367
]
13841368
},
@@ -1389,13 +1373,11 @@
13891373
"header": [],
13901374
"body": {},
13911375
"url": {
1392-
"raw": "https://704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1.mock.pstmn.io/copy",
1376+
"raw": "https://postman-echo.com/copy",
13931377
"protocol": "https",
13941378
"host": [
1395-
"704c30e8-77fe-4dc4-93e2-9c9c68dfb4e1",
1396-
"mock",
1397-
"pstmn",
1398-
"io"
1379+
"postman-echo",
1380+
"com"
13991381
],
14001382
"path": [
14011383
"copy"
@@ -1411,11 +1393,11 @@
14111393
"header": [],
14121394
"body": {},
14131395
"url": {
1414-
"raw": "https://mockbin.org/request",
1396+
"raw": "https://postman-echo.com/request",
14151397
"protocol": "https",
14161398
"host": [
1417-
"mockbin",
1418-
"org"
1399+
"postman-echo",
1400+
"com"
14191401
],
14201402
"path": [
14211403
"request"
@@ -1527,14 +1509,14 @@
15271509
{
15281510
"expires": "Thu Mar 14 2019 13:12:10 GMT+0530 (IST)",
15291511
"httpOnly": true,
1530-
"domain": "mockbin.org",
1512+
"domain": "postman-echo.com",
15311513
"path": "/",
15321514
"secure": false,
15331515
"value": "dfb94a3e1f3f8a9956138e4896847caf21521013330",
15341516
"key": "__cfduid"
15351517
}
15361518
],
1537-
"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}"
1519+
"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}"
15381520
}
15391521
]
15401522
}

codegens/curl/lib/util.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ var self = module.exports = {
2929
inputString = inputString.replace(/"/g, '\\"');
3030
// Escape backslash if double quote was already escaped before call to sanitize
3131
inputString = inputString.replace(/(?<!\\)\\\\"/g, '\\\\\\"');
32+
33+
// Escape special characters to preserve their literal meaning within double quotes
34+
inputString = inputString
35+
.replace(/`/g, '\\`')
36+
.replace(/#/g, '\\#')
37+
.replace(/\$/g, '\\$')
38+
.replace(/!/g, '\\!');
3239
}
3340
else if (quoteType === '\'') {
3441
// for curl escaping of single quotes inside single quotes involves changing of ' to '\''
@@ -207,7 +214,7 @@ var self = module.exports = {
207214
},
208215

209216
/**
210-
* Encode param except the following characters- [,{,},],%
217+
* Encode param except the following characters- [,{,},],%,+
211218
*
212219
* @param {String} param
213220
* @returns {String}
@@ -218,6 +225,7 @@ var self = module.exports = {
218225
.replace(/%7B/g, '{')
219226
.replace(/%5D/g, ']')
220227
.replace(/%7D/g, '}')
228+
.replace(/%2B/g, '+')
221229
.replace(/%25/g, '%')
222230
.replace(/'/g, '%27');
223231
},

codegens/curl/test/unit/convert.test.js

+37-3
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,40 @@ describe('curl convert function', function () {
537537
});
538538
});
539539

540+
it('should escape special characters when quoteType is "double"', function () {
541+
var request = new sdk.Request({
542+
'method': 'POST',
543+
'header': [],
544+
'body': {
545+
'mode': 'raw',
546+
'raw': '{\r\n "hello": "$(whoami)"\r\n}',
547+
'options': {
548+
'raw': {
549+
'language': 'json'
550+
}
551+
}
552+
},
553+
'url': {
554+
'raw': 'https://postman-echo.com/post',
555+
'protocol': 'https',
556+
'host': [
557+
'postman-echo',
558+
'com'
559+
],
560+
'path': [
561+
'post'
562+
]
563+
}
564+
});
565+
convert(request, { quoteType: 'double', lineContinuationCharacter: '^' }, function (error, snippet) {
566+
if (error) {
567+
expect.fail(null, null, error);
568+
}
569+
570+
expect(snippet.includes('\\"hello\\": \\"\\$(whoami)\\"')).to.be.true; // eslint-disable-line
571+
});
572+
});
573+
540574
it('should longer option for body even if longFormat is disabled if @ character is present', function () {
541575
let request = new sdk.Request({
542576
'method': 'POST',
@@ -642,12 +676,12 @@ describe('curl convert function', function () {
642676

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

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

0 commit comments

Comments
 (0)