From ed829a477222f169e4ff0727db920e8029fd0c7d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 4 May 2019 17:32:17 +0100 Subject: JS: Attribute external JS to the URI it came from in backtraces Signed-off-by: Daniel Silverstone --- content/handlers/javascript/duktape/dukky.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'content/handlers/javascript/duktape/dukky.c') diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index e9e72650c..171736338 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -716,7 +716,7 @@ duk_int_t dukky_pcall(duk_context *ctx, duk_size_t argc, bool reset_timeout) } -bool js_exec(jscontext *ctx, const char *txt, size_t txtlen) +bool js_exec(jscontext *ctx, const char *txt, size_t txtlen, const char *name) { assert(ctx); if (txt == NULL || txtlen == 0) return false; @@ -724,7 +724,11 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen) NSLOG(dukky, DEEPDEBUG, "%zd bytes: %s", txtlen, txt); (void) nsu_getmonotonic_ms(&ctx->exec_start_time); - duk_push_string(CTX, "?unknown source?"); + if (name != NULL) { + duk_push_string(CTX, name); + } else { + duk_push_string(CTX, "?unknown source?"); + } if (duk_pcompile_lstring_filename(CTX, DUK_COMPILE_EVAL, txt, txtlen) != 0) { NSLOG(dukky, INFO, "Failed to compile JavaScript input"); goto handle_error; -- cgit v1.2.3