Skip to content

Commit

Permalink
Do not allow complex types in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nizox committed Jun 29, 2020
1 parent 16f20c1 commit 7631fa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py_mini_racer/extension/mini_racer_extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,18 @@ static BinaryValue* MiniRacer_eval_context_unsafe(
Local<Value> tmp = Local<Value>::New(context_info->isolate,
*eval_result.message);

bmessage = convert_v8_to_binary(context_info->isolate, *context_info->context, tmp);
if (eval_params.basic_only) {
bmessage = convert_basic_v8_to_binary(context_info->isolate, *context_info->context, tmp);
} else {
bmessage = convert_v8_to_binary(context_info->isolate, *context_info->context, tmp);
}
}

if (eval_result.backtrace) {

Local<Value> tmp = Local<Value>::New(context_info->isolate,
*eval_result.backtrace);
bbacktrace = convert_v8_to_binary(context_info->isolate, *context_info->context, tmp);
bbacktrace = convert_basic_v8_to_binary(context_info->isolate, *context_info->context, tmp);
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/test_strict.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ def test_call(self):

self.assertIsNone(self.mr.eval(js_func))
self.assertEqual(self.mr.call('f', list(range(5))), 5)

def test_message(self):
with self.assertRaises(py_mini_racer.JSEvalException):
res = self.mr.eval("throw new EvalError('Hello', 'someFile.js', 10);")

0 comments on commit 7631fa5

Please # to comment.