GeezerVison is showing github.com — sea: reject trailing content in config JSON · nodejs/node@64a8843
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_sea.cc +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -541,6 +541,14 @@ std::optional<SeaConfig> ParseSingleExecutableConfig( |
541 | 541 | } |
542 | 542 | } |
543 | 543 |
|
| 544 | + if (!document.at_end()) { |
| 545 | + FPrintF(stderr, |
| 546 | + "Cannot parse JSON from %s: %s\n", |
| 547 | + config_path, |
| 548 | + simdjson::error_message(simdjson::TRAILING_CONTENT)); |
| 549 | + return std::nullopt; |
| 550 | + } |
| 551 | + |
544 | 552 | if (static_cast<bool>(result.flags & SeaFlags::kUseSnapshot) && |
545 | 553 | static_cast<bool>(result.flags & SeaFlags::kUseCodeCache)) { |
546 | 554 | // TODO(joyeecheung): code cache in snapshot should be configured by |
|
Collapse file
Copy file name to clipboardExpand all lines: test/sea/test-single-executable-blob-config-errors.js +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,6 +47,24 @@ const { spawnSyncAndAssert } = require('../common/child_process'); |
47 | 47 | }); |
48 | 48 | } |
49 | 49 |
|
| 50 | +{ |
| 51 | + tmpdir.refresh(); |
| 52 | + const config = tmpdir.resolve('trailing-content.json'); |
| 53 | + writeFileSync( |
| 54 | + config, |
| 55 | + '{"main":"bundle.js","output":"sea.blob"}{}', |
| 56 | + 'utf8', |
| 57 | + ); |
| 58 | + spawnSyncAndAssert( |
| 59 | + process.execPath, |
| 60 | + ['--experimental-sea-config', config], { |
| 61 | + cwd: tmpdir.path, |
| 62 | + }, { |
| 63 | + status: 1, |
| 64 | + stderr: /TRAILING_CONTENT/, |
| 65 | + }); |
| 66 | +} |
| 67 | + |
50 | 68 | { |
51 | 69 | tmpdir.refresh(); |
52 | 70 | const config = tmpdir.resolve('empty.json'); |
|