| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3a77d21 commit af5e1a9
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,10 +171,10 @@ std::string EscapeShell(const std::string_view input) { | |||
| 171 | 171 | escaped = std::regex_replace(escaped, leadingQuotePairs, ""); | |
| 172 | 172 | escaped = std::regex_replace(escaped, tripleSingleQuote, "\\\""); | |
| 173 | 173 | #else | |
| 174 | - // Replace single quotes("'") with "\\'" and wrap the result | ||
| 174 | + // Replace single quotes("'") with `'"'"'` and wrap the result | ||
| 175 | 175 | // in single quotes. | |
| 176 | 176 | std::string escaped = | |
| 177 | - std::regex_replace(std::string(input), std::regex("'"), "\\'"); | ||
| 177 | + std::regex_replace(std::string(input), std::regex("'"), "'\"'\"'"); | ||
| 178 | 178 | escaped = "'" + escaped + "'"; | |
| 179 | 179 | // Remove excessive quote pairs and handle edge cases | |
| 180 | 180 | static const std::regex tripleSingleQuote("\\\\'''"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,12 +28,12 @@ TEST_F(TaskRunnerTest, EscapeShell) { | |||
| 28 | 28 | {"test words", "'test words'"}, | |
| 29 | 29 | {"$1", "'$1'"}, | |
| 30 | 30 | {"\"$1\"", "'\"$1\"'"}, | |
| 31 | - {"'$1'", "'\\'$1\\''"}, | ||
| 31 | + {"'$1'", "\"'\"'$1'\"'\"''"}, | ||
| 32 | 32 | {"\\$1", "'\\$1'"}, | |
| 33 | 33 | {"--arg=\"$1\"", "'--arg=\"$1\"'"}, | |
| 34 | 34 | {"--arg=node exec -c \"$1\"", "'--arg=node exec -c \"$1\"'"}, | |
| 35 | - {"--arg=node exec -c '$1'", "'--arg=node exec -c \\'$1\\''"}, | ||
| 36 | - {"'--arg=node exec -c \"$1\"'", "'\\'--arg=node exec -c \"$1\"\\''"} | ||
| 35 | + {"--arg=node exec -c '$1'", "'--arg=node exec -c '\"'\"'$1'\"'\"''"}, | ||
| 36 | + {"'--arg=node exec -c \"$1\"'", "\"'\"'--arg=node exec -c \"$1\"'\"'\"''"} | ||
| 37 | 37 | #endif | |
| 38 | 38 | }; | |
| 39 | 39 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -143,15 +143,15 @@ describe('node --run [command]', () => { | |||
| 143 | 143 | it('appends positional arguments', async () => { | |
| 144 | 144 | const child = await common.spawnPromisified( | |
| 145 | 145 | process.execPath, | |
| 146 | - [ '--run', `positional-args${envSuffix}`, '--', '--help "hello world test"', 'A', 'B', 'C'], | ||
| 146 | + [ '--run', `positional-args${envSuffix}`, '--', '--help "hello world test"', 'A', 'B', 'C', 'I think therefore I\'m'], | ||
| 147 | 147 | { cwd: fixtures.path('run-script') }, | |
| 148 | 148 | ); | |
| 149 | 149 | if (common.isWindows) { | |
| 150 | - assert.match(child.stdout, /Arguments: '--help ""hello world test"" A B C'/); | ||
| 150 | + assert.match(child.stdout, /Arguments: '--help ""hello world test"" A B C I think therefore I'm'/); | ||
| 151 | 151 | } else { | |
| 152 | - assert.match(child.stdout, /Arguments: '--help "hello world test" A B C'/); | ||
| 152 | + assert.match(child.stdout, /Arguments: '--help "hello world test" A B C I think therefore I'm'/); | ||
| 153 | 153 | } | |
| 154 | - assert.match(child.stdout, /The total number of arguments are: 4/); | ||
| 154 | + assert.match(child.stdout, /The total number of arguments is: 5/); | ||
| 155 | 155 | assert.strictEqual(child.stderr, ''); | |
| 156 | 156 | assert.strictEqual(child.code, 0); | |
| 157 | 157 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments