@theia/process 1.34.2 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/common/process-common-module.d.ts +3 -3
  4. package/lib/common/process-common-module.js +22 -22
  5. package/lib/common/process-manager-types.d.ts +35 -35
  6. package/lib/common/process-manager-types.js +23 -23
  7. package/lib/common/shell-command-builder.d.ts +49 -49
  8. package/lib/common/shell-command-builder.js +174 -174
  9. package/lib/common/shell-command-builder.slow-spec.d.ts +9 -9
  10. package/lib/common/shell-command-builder.slow-spec.js +404 -404
  11. package/lib/common/shell-quoting.d.ts +91 -91
  12. package/lib/common/shell-quoting.js +145 -145
  13. package/lib/common/shell-quoting.spec.d.ts +1 -1
  14. package/lib/common/shell-quoting.spec.js +170 -170
  15. package/lib/node/dev-null-stream.d.ts +17 -17
  16. package/lib/node/dev-null-stream.js +41 -41
  17. package/lib/node/index.d.ts +6 -6
  18. package/lib/node/index.js +33 -33
  19. package/lib/node/multi-ring-buffer.d.ts +68 -68
  20. package/lib/node/multi-ring-buffer.js +310 -310
  21. package/lib/node/multi-ring-buffer.spec.d.ts +1 -1
  22. package/lib/node/multi-ring-buffer.spec.js +422 -422
  23. package/lib/node/process-backend-module.d.ts +3 -3
  24. package/lib/node/process-backend-module.js +56 -56
  25. package/lib/node/process-manager.d.ts +33 -33
  26. package/lib/node/process-manager.js +113 -113
  27. package/lib/node/process.d.ts +95 -95
  28. package/lib/node/process.js +153 -153
  29. package/lib/node/pseudo-pty.d.ts +22 -22
  30. package/lib/node/pseudo-pty.js +38 -38
  31. package/lib/node/raw-process.d.ts +45 -45
  32. package/lib/node/raw-process.js +115 -115
  33. package/lib/node/raw-process.spec.d.ts +1 -1
  34. package/lib/node/raw-process.spec.js +164 -164
  35. package/lib/node/task-terminal-process.d.ts +10 -10
  36. package/lib/node/task-terminal-process.js +47 -47
  37. package/lib/node/terminal-process.d.ts +49 -49
  38. package/lib/node/terminal-process.js +180 -180
  39. package/lib/node/terminal-process.spec.d.ts +1 -1
  40. package/lib/node/terminal-process.spec.js +89 -89
  41. package/lib/node/test/process-test-container.d.ts +2 -2
  42. package/lib/node/test/process-test-container.js +28 -28
  43. package/lib/node/utils.d.ts +16 -16
  44. package/lib/node/utils.js +77 -77
  45. package/package.json +4 -4
  46. package/src/common/process-common-module.ts +22 -22
  47. package/src/common/process-manager-types.ts +58 -58
  48. package/src/common/shell-command-builder.slow-spec.ts +486 -486
  49. package/src/common/shell-command-builder.ts +187 -187
  50. package/src/common/shell-quoting.spec.ts +176 -176
  51. package/src/common/shell-quoting.ts +236 -236
  52. package/src/common/tests/$weird(),file=name.js +1 -1
  53. package/src/common/tests/white space.js +1 -1
  54. package/src/node/dev-null-stream.ts +47 -47
  55. package/src/node/index.ts +22 -22
  56. package/src/node/multi-ring-buffer.spec.ts +486 -486
  57. package/src/node/multi-ring-buffer.ts +348 -348
  58. package/src/node/process-backend-module.ts +67 -67
  59. package/src/node/process-manager.ts +107 -107
  60. package/src/node/process.ts +207 -207
  61. package/src/node/pseudo-pty.ts +54 -54
  62. package/src/node/raw-process.spec.ts +199 -199
  63. package/src/node/raw-process.ts +156 -156
  64. package/src/node/string-argv.d.ts +21 -21
  65. package/src/node/task-terminal-process.ts +41 -41
  66. package/src/node/terminal-process.spec.ts +104 -104
  67. package/src/node/terminal-process.ts +198 -198
  68. package/src/node/test/process-fork-test.js +22 -22
  69. package/src/node/test/process-test-container.ts +27 -27
  70. package/src/node/utils.ts +79 -79
@@ -1,176 +1,176 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { expect } from 'chai';
18
-
19
- import { escapeForShell, BashQuotingFunctions, ShellQuoting, CmdQuotingFunctions, PowershellQuotingFunctions } from './shell-quoting';
20
-
21
- describe('Shell arguments escaping:', () => {
22
-
23
- // Procedurally execute tests from this list of data.
24
- const testData = {
25
- bash: {
26
- // https://www.gnu.org/software/bash/manual/html_node/Quoting.html
27
- quotingFunctions: BashQuotingFunctions,
28
- data: {
29
- [ShellQuoting.Escape]: [
30
- { input: 'abc', expected: 'abc' },
31
- { input: 'ab c', expected: 'ab\\ c' },
32
- { input: 'ab"c', expected: 'ab\\"c' },
33
- { input: 'ab\'c', expected: 'ab\\\'c' },
34
- { input: 'ab\\ c\\', expected: 'ab\\\\\\ c\\\\' },
35
- {
36
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
37
- expected: 'setTimeout\\(\\(\\)\\ =\\>\\ \\{\\ console.log\\(1,\\ \\"2\\\'3\\"\\)\\;\\ \\},\\ 100\\)',
38
- },
39
- ],
40
- [ShellQuoting.Strong]: [
41
- { input: 'abc', expected: '\'abc\'' },
42
- { input: 'ab c', expected: '\'ab c\'' },
43
- { input: 'ab"c', expected: '\'ab"c\'' },
44
- { input: 'ab\'c', expected: '\'ab\'"\'"\'c\'' },
45
- { input: 'ab\\ c\\', expected: '\'ab\\ c\\\'' },
46
- {
47
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
48
- expected: '\'setTimeout(() => { console.log(1, "2\'"\'"\'3"); }, 100)\'',
49
- },
50
- ],
51
- [ShellQuoting.Weak]: [
52
- { input: 'abc', expected: '"abc"' },
53
- { input: 'ab c', expected: '"ab c"' },
54
- { input: 'ab"c', expected: '"ab\\"c"' },
55
- { input: 'ab\'c', expected: '"ab\'c"' },
56
- { input: 'ab\\ c\\', expected: '"ab\\ c\\\\"' },
57
- {
58
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
59
- expected: '"setTimeout(() => { console.log(1, \\"2\'3\\"); }, 100)"',
60
- },
61
- ]
62
- },
63
- },
64
- cmd: {
65
- // https://ss64.com/nt/syntax-esc.html
66
- quotingFunctions: CmdQuotingFunctions,
67
- data: {
68
- [ShellQuoting.Escape]: [
69
- { input: 'abc', expected: 'abc' },
70
- { input: 'ab c', expected: 'ab" "c' },
71
- { input: 'ab"c', expected: 'ab\\"c' },
72
- { input: 'ab\'c', expected: 'ab\'c' },
73
- { input: 'ab^ c^', expected: 'ab^^" "c^^' },
74
- {
75
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
76
- expected: 'setTimeout^(^(^)" "=^>" "{" "console.log^(1," "\\"2\'3\\"^);" "}," "100^)',
77
- },
78
- {
79
- input: 'console.log("%PATH%")',
80
- expected: 'console.log^(\\"^%PATH^%\\"^)',
81
- },
82
- ],
83
- [ShellQuoting.Strong]: [
84
- { input: 'abc', expected: '"abc"' },
85
- { input: 'ab c', expected: '"ab c"' },
86
- { input: 'ab"c', expected: '"ab\\"c"' },
87
- { input: 'ab\'c', expected: '"ab\'c"' },
88
- { input: 'ab^ c^', expected: '"ab^^ c^^"' },
89
- {
90
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
91
- expected: '"setTimeout^(^(^) =^> { console.log^(1, \\"2\'3\\"^); }, 100^)"',
92
- },
93
- {
94
- input: 'console.log("%PATH%")',
95
- expected: '"console.log^(\\""%"PATH"%"\\"^)"',
96
- },
97
- ],
98
- [ShellQuoting.Weak]: [
99
- { input: 'abc', expected: '"abc"' },
100
- { input: 'ab c', expected: '"ab c"' },
101
- { input: 'ab"c', expected: '"ab\\"c"' },
102
- { input: 'ab\'c', expected: '"ab\'c"' },
103
- { input: 'ab^ c^', expected: '"ab^^ c^^"' },
104
- {
105
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
106
- expected: '"setTimeout^(^(^) =^> { console.log^(1, \\"2\'3\\"^); }, 100^)"',
107
- },
108
- {
109
- input: 'console.log("%PATH%")',
110
- expected: '"console.log^(\\"%PATH%\\"^)"',
111
- },
112
- ]
113
- },
114
- },
115
- powershell: {
116
- // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-6
117
- quotingFunctions: PowershellQuotingFunctions,
118
- data: {
119
- [ShellQuoting.Escape]: [
120
- { input: 'abc', expected: 'abc' },
121
- { input: 'ab c', expected: 'ab` c' },
122
- { input: 'ab"c', expected: 'ab`"c' },
123
- { input: 'ab\'c', expected: 'ab`\'c' },
124
- { input: 'ab` c`', expected: 'ab``` c``' },
125
- {
126
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
127
- expected: 'setTimeout`(`(`)` =`>` `{` console.log`(1,` `"2`\'3`"`)`;` `},` 100`)',
128
- },
129
- ],
130
- [ShellQuoting.Strong]: [
131
- { input: 'abc', expected: '\'abc\'' },
132
- { input: 'ab c', expected: '\'ab c\'' },
133
- { input: 'ab"c', expected: '\'ab"c\'' },
134
- { input: 'ab\'c', expected: '\'ab\'\'c\'' },
135
- { input: 'ab` c`', expected: '\'ab` c`\'' },
136
- {
137
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
138
- expected: '\'setTimeout(() => { console.log(1, "2\'\'3"); }, 100)\'',
139
- },
140
- ],
141
- [ShellQuoting.Weak]: [
142
- { input: 'abc', expected: '"abc"' },
143
- { input: 'ab c', expected: '"ab c"' },
144
- { input: 'ab"c', expected: '"ab`"c"' },
145
- { input: 'ab\'c', expected: '"ab\'c"' },
146
- { input: 'ab` c`', expected: '"ab` c``"' },
147
- {
148
- input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
149
- expected: '"setTimeout(() => { console.log(1, `"2\'3`"); }, 100)"',
150
- },
151
- ]
152
- },
153
- }
154
- } as const;
155
-
156
- // Iter through each runtime (bash/cmd/powershell):
157
- for (const runtime of Object.keys(testData)) {
158
- const testInfo = testData[runtime as keyof typeof testData];
159
-
160
- // Get all quoting types (escape/strong/weak):
161
- for (const quotingType of Object.keys(testInfo.data)) {
162
- const testInput = testInfo.data[quotingType as keyof typeof testInfo['data']];
163
-
164
- // Run the test for each input:
165
- it(`${runtime}/${quotingType}`, () => {
166
- for (const test of testInput) {
167
- expect(escapeForShell({
168
- quoting: quotingType as ShellQuoting,
169
- value: test.input,
170
- }, testInfo.quotingFunctions)).equal(test.expected);
171
- }
172
- });
173
- }
174
- }
175
-
176
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { expect } from 'chai';
18
+
19
+ import { escapeForShell, BashQuotingFunctions, ShellQuoting, CmdQuotingFunctions, PowershellQuotingFunctions } from './shell-quoting';
20
+
21
+ describe('Shell arguments escaping:', () => {
22
+
23
+ // Procedurally execute tests from this list of data.
24
+ const testData = {
25
+ bash: {
26
+ // https://www.gnu.org/software/bash/manual/html_node/Quoting.html
27
+ quotingFunctions: BashQuotingFunctions,
28
+ data: {
29
+ [ShellQuoting.Escape]: [
30
+ { input: 'abc', expected: 'abc' },
31
+ { input: 'ab c', expected: 'ab\\ c' },
32
+ { input: 'ab"c', expected: 'ab\\"c' },
33
+ { input: 'ab\'c', expected: 'ab\\\'c' },
34
+ { input: 'ab\\ c\\', expected: 'ab\\\\\\ c\\\\' },
35
+ {
36
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
37
+ expected: 'setTimeout\\(\\(\\)\\ =\\>\\ \\{\\ console.log\\(1,\\ \\"2\\\'3\\"\\)\\;\\ \\},\\ 100\\)',
38
+ },
39
+ ],
40
+ [ShellQuoting.Strong]: [
41
+ { input: 'abc', expected: '\'abc\'' },
42
+ { input: 'ab c', expected: '\'ab c\'' },
43
+ { input: 'ab"c', expected: '\'ab"c\'' },
44
+ { input: 'ab\'c', expected: '\'ab\'"\'"\'c\'' },
45
+ { input: 'ab\\ c\\', expected: '\'ab\\ c\\\'' },
46
+ {
47
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
48
+ expected: '\'setTimeout(() => { console.log(1, "2\'"\'"\'3"); }, 100)\'',
49
+ },
50
+ ],
51
+ [ShellQuoting.Weak]: [
52
+ { input: 'abc', expected: '"abc"' },
53
+ { input: 'ab c', expected: '"ab c"' },
54
+ { input: 'ab"c', expected: '"ab\\"c"' },
55
+ { input: 'ab\'c', expected: '"ab\'c"' },
56
+ { input: 'ab\\ c\\', expected: '"ab\\ c\\\\"' },
57
+ {
58
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
59
+ expected: '"setTimeout(() => { console.log(1, \\"2\'3\\"); }, 100)"',
60
+ },
61
+ ]
62
+ },
63
+ },
64
+ cmd: {
65
+ // https://ss64.com/nt/syntax-esc.html
66
+ quotingFunctions: CmdQuotingFunctions,
67
+ data: {
68
+ [ShellQuoting.Escape]: [
69
+ { input: 'abc', expected: 'abc' },
70
+ { input: 'ab c', expected: 'ab" "c' },
71
+ { input: 'ab"c', expected: 'ab\\"c' },
72
+ { input: 'ab\'c', expected: 'ab\'c' },
73
+ { input: 'ab^ c^', expected: 'ab^^" "c^^' },
74
+ {
75
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
76
+ expected: 'setTimeout^(^(^)" "=^>" "{" "console.log^(1," "\\"2\'3\\"^);" "}," "100^)',
77
+ },
78
+ {
79
+ input: 'console.log("%PATH%")',
80
+ expected: 'console.log^(\\"^%PATH^%\\"^)',
81
+ },
82
+ ],
83
+ [ShellQuoting.Strong]: [
84
+ { input: 'abc', expected: '"abc"' },
85
+ { input: 'ab c', expected: '"ab c"' },
86
+ { input: 'ab"c', expected: '"ab\\"c"' },
87
+ { input: 'ab\'c', expected: '"ab\'c"' },
88
+ { input: 'ab^ c^', expected: '"ab^^ c^^"' },
89
+ {
90
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
91
+ expected: '"setTimeout^(^(^) =^> { console.log^(1, \\"2\'3\\"^); }, 100^)"',
92
+ },
93
+ {
94
+ input: 'console.log("%PATH%")',
95
+ expected: '"console.log^(\\""%"PATH"%"\\"^)"',
96
+ },
97
+ ],
98
+ [ShellQuoting.Weak]: [
99
+ { input: 'abc', expected: '"abc"' },
100
+ { input: 'ab c', expected: '"ab c"' },
101
+ { input: 'ab"c', expected: '"ab\\"c"' },
102
+ { input: 'ab\'c', expected: '"ab\'c"' },
103
+ { input: 'ab^ c^', expected: '"ab^^ c^^"' },
104
+ {
105
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
106
+ expected: '"setTimeout^(^(^) =^> { console.log^(1, \\"2\'3\\"^); }, 100^)"',
107
+ },
108
+ {
109
+ input: 'console.log("%PATH%")',
110
+ expected: '"console.log^(\\"%PATH%\\"^)"',
111
+ },
112
+ ]
113
+ },
114
+ },
115
+ powershell: {
116
+ // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-6
117
+ quotingFunctions: PowershellQuotingFunctions,
118
+ data: {
119
+ [ShellQuoting.Escape]: [
120
+ { input: 'abc', expected: 'abc' },
121
+ { input: 'ab c', expected: 'ab` c' },
122
+ { input: 'ab"c', expected: 'ab`"c' },
123
+ { input: 'ab\'c', expected: 'ab`\'c' },
124
+ { input: 'ab` c`', expected: 'ab``` c``' },
125
+ {
126
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
127
+ expected: 'setTimeout`(`(`)` =`>` `{` console.log`(1,` `"2`\'3`"`)`;` `},` 100`)',
128
+ },
129
+ ],
130
+ [ShellQuoting.Strong]: [
131
+ { input: 'abc', expected: '\'abc\'' },
132
+ { input: 'ab c', expected: '\'ab c\'' },
133
+ { input: 'ab"c', expected: '\'ab"c\'' },
134
+ { input: 'ab\'c', expected: '\'ab\'\'c\'' },
135
+ { input: 'ab` c`', expected: '\'ab` c`\'' },
136
+ {
137
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
138
+ expected: '\'setTimeout(() => { console.log(1, "2\'\'3"); }, 100)\'',
139
+ },
140
+ ],
141
+ [ShellQuoting.Weak]: [
142
+ { input: 'abc', expected: '"abc"' },
143
+ { input: 'ab c', expected: '"ab c"' },
144
+ { input: 'ab"c', expected: '"ab`"c"' },
145
+ { input: 'ab\'c', expected: '"ab\'c"' },
146
+ { input: 'ab` c`', expected: '"ab` c``"' },
147
+ {
148
+ input: 'setTimeout(() => { console.log(1, "2\'3"); }, 100)',
149
+ expected: '"setTimeout(() => { console.log(1, `"2\'3`"); }, 100)"',
150
+ },
151
+ ]
152
+ },
153
+ }
154
+ } as const;
155
+
156
+ // Iter through each runtime (bash/cmd/powershell):
157
+ for (const runtime of Object.keys(testData)) {
158
+ const testInfo = testData[runtime as keyof typeof testData];
159
+
160
+ // Get all quoting types (escape/strong/weak):
161
+ for (const quotingType of Object.keys(testInfo.data)) {
162
+ const testInput = testInfo.data[quotingType as keyof typeof testInfo['data']];
163
+
164
+ // Run the test for each input:
165
+ it(`${runtime}/${quotingType}`, () => {
166
+ for (const test of testInput) {
167
+ expect(escapeForShell({
168
+ quoting: quotingType as ShellQuoting,
169
+ value: test.input,
170
+ }, testInfo.quotingFunctions)).equal(test.expected);
171
+ }
172
+ });
173
+ }
174
+ }
175
+
176
+ });