mirror of https://github.com/electron/electron
36 lines
1.3 KiB
Diff
36 lines
1.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Attard <sattard@slack-corp.com>
|
|
Date: Wed, 22 May 2019 13:34:18 -0700
|
|
Subject: chore: add context to context aware module prevention
|
|
|
|
This patch adds extra context to why we prevent non-context-aware Node.js
|
|
modules from being used in the renderer process. This should be upstreamed as
|
|
a customizable error message.
|
|
|
|
diff --git a/src/node_binding.cc b/src/node_binding.cc
|
|
index 8cdee730101fbdc79415654aa6fe401573979c0e..34d5e146ffef255019dd33d8c23b0847d91ddee9 100644
|
|
--- a/src/node_binding.cc
|
|
+++ b/src/node_binding.cc
|
|
@@ -4,6 +4,7 @@
|
|
#include "node_builtins.h"
|
|
#include "node_errors.h"
|
|
#include "node_external_reference.h"
|
|
+#include "node_process.h"
|
|
#include "util.h"
|
|
|
|
#include <string>
|
|
@@ -480,7 +481,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
|
if (mp->nm_context_register_func == nullptr) {
|
|
if (env->force_context_aware()) {
|
|
dlib->Close();
|
|
- THROW_ERR_NON_CONTEXT_AWARE_DISABLED(env);
|
|
+ char errmsg[1024];
|
|
+ snprintf(errmsg,
|
|
+ sizeof(errmsg),
|
|
+ "Loading non-context-aware native module in renderer: '%s'. See https://github.com/electron/electron/issues/18397.",
|
|
+ *filename);
|
|
+ env->ThrowError(errmsg);
|
|
return false;
|
|
}
|
|
}
|