| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 001c37c commit 1d9dd25
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1631,7 +1631,14 @@ static ExitCode StartInternal(int argc, char** argv) { | |||
| 1631 | 1631 | ||
| 1632 | 1632 | int Start(int argc, char** argv) { | |
| 1633 | 1633 | #ifndef DISABLE_SINGLE_EXECUTABLE_APPLICATION | |
| 1634 | - std::tie(argc, argv) = sea::FixupArgsForSEA(argc, argv); | ||
| 1634 | + std::vector<std::string> errors; | ||
| 1635 | + std::tie(argc, argv) = sea::FixupArgsForSEA(argc, argv, &errors); | ||
| 1636 | + if (!errors.empty()) { | ||
| 1637 | + for (const std::string& error : errors) { | ||
| 1638 | + FPrintF(stderr, "%s: %s\n", argv[0], error); | ||
| 1639 | + } | ||
| 1640 | + return static_cast<int>(ExitCode::kInvalidCommandLineArgument); | ||
| 1641 | + } | ||
| 1635 | 1642 | #endif | |
| 1636 | 1643 | return static_cast<int>(StartInternal(argc, argv)); | |
| 1637 | 1644 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -283,7 +283,9 @@ void IsExperimentalSeaWarningNeeded(const FunctionCallbackInfo<Value>& args) { | |||
| 283 | 283 | sea_resource.flags & SeaFlags::kDisableExperimentalSeaWarning)); | |
| 284 | 284 | } | |
| 285 | 285 | ||
| 286 | - std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv) { | ||
| 286 | + std::tuple<int, char**> FixupArgsForSEA(int argc, | ||
| 287 | + char** argv, | ||
| 288 | + std::vector<std::string>* errors) { | ||
| 287 | 289 | // Repeats argv[0] at position 1 on argv as a replacement for the missing | |
| 288 | 290 | // entry point file path. | |
| 289 | 291 | if (IsSingleExecutable()) { | |
@@ -303,8 +305,10 @@ std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv) { | |||
| 303 | 305 | for (int i = 1; i < argc; ++i) { | |
| 304 | 306 | if (strncmp(argv[i], "--node-options=", 15) == 0) { | |
| 305 | 307 | std::string node_options = argv[i] + 15; | |
| 306 | - std::vector<std::string> errors; | ||
| 307 | - cli_extension_args = ParseNodeOptionsEnvVar(node_options, &errors); | ||
| 308 | + cli_extension_args = ParseNodeOptionsEnvVar(node_options, errors); | ||
| 309 | + if (!errors->empty()) { | ||
| 310 | + return {argc, argv}; | ||
| 311 | + } | ||
| 308 | 312 | // Remove this argument by shifting the rest | |
| 309 | 313 | for (int j = i; j < argc - 1; ++j) { | |
| 310 | 314 | argv[j] = argv[j + 1]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,7 +70,9 @@ struct SeaResource { | |||
| 70 | 70 | bool IsSingleExecutable(); | |
| 71 | 71 | std::string_view FindSingleExecutableBlob(); | |
| 72 | 72 | SeaResource FindSingleExecutableResource(); | |
| 73 | - std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv); | ||
| 73 | + std::tuple<int, char**> FixupArgsForSEA(int argc, | ||
| 74 | + char** argv, | ||
| 75 | + std::vector<std::string>* errors); | ||
| 74 | 76 | node::ExitCode WriteSingleExecutableBlob( | |
| 75 | 77 | const std::string& config_path, | |
| 76 | 78 | const std::vector<std::string>& args, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,18 +20,36 @@ tmpdir.refresh(); | |||
| 20 | 20 | ||
| 21 | 21 | const outputFile = buildSEA(fixtures.path('sea', 'exec-argv-extension-cli')); | |
| 22 | 22 | ||
| 23 | + const env = { | ||
| 24 | + ...process.env, | ||
| 25 | + NODE_OPTIONS: '--max-old-space-size=2048', // Should be ignored | ||
| 26 | + COMMON_DIRECTORY: join(__dirname, '..', 'common'), | ||
| 27 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 28 | + }; | ||
| 29 | + | ||
| 23 | 30 | // Test that --node-options works with execArgvExtension: "cli" | |
| 24 | 31 | spawnSyncAndAssert( | |
| 25 | 32 | outputFile, | |
| 26 | 33 | ['--node-options=--max-old-space-size=1024', 'user-arg1', 'user-arg2'], | |
| 27 | 34 | { | |
| 28 | - env: { | ||
| 29 | - ...process.env, | ||
| 30 | - NODE_OPTIONS: '--max-old-space-size=2048', // Should be ignored | ||
| 31 | - COMMON_DIRECTORY: join(__dirname, '..', 'common'), | ||
| 32 | - NODE_DEBUG_NATIVE: 'SEA', | ||
| 33 | - }, | ||
| 35 | + env, | ||
| 34 | 36 | }, | |
| 35 | 37 | { | |
| 36 | 38 | stdout: /execArgvExtension cli test passed/, | |
| 37 | 39 | }); | |
| 40 | + | ||
| 41 | + // Test that malformed --node-options values are rejected. | ||
| 42 | + [ | ||
| 43 | + ['--no-warnings "', /unterminated string/], | ||
| 44 | + ['"--no-warnings\\', /invalid escape/], | ||
| 45 | + ].forEach(([nodeOptions, stderr]) => { | ||
| 46 | + spawnSyncAndAssert( | ||
| 47 | + outputFile, | ||
| 48 | + [`--node-options=${nodeOptions}`], | ||
| 49 | + { env }, | ||
| 50 | + { | ||
| 51 | + status: 9, | ||
| 52 | + stdout: '', | ||
| 53 | + stderr, | ||
| 54 | + }); | ||
| 55 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments