From dd7ab069c801dc83cfc0222cc692c34c7d248da1 Mon Sep 17 00:00:00 2001 From: Alexander Borisov Date: Thu, 8 Oct 2020 18:47:04 +0300 Subject: [PATCH] HTTP: throwing an exception in internalRedirect() for a subrequest. This closes #214 issue on GitHub. --- nginx/ngx_http_js_module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index e9132fd8..4e2f0077 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -1831,6 +1831,11 @@ ngx_http_js_ext_internal_redirect(njs_vm_t *vm, njs_value_t *args, return NJS_ERROR; } + if (r->parent != NULL) { + njs_vm_error(vm, "internalRedirect cannot be called from a subrequest"); + return NJS_ERROR; + } + ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); if (ngx_http_js_string(vm, njs_arg(args, nargs, 1), &uri) != NJS_OK) { -- 2.47.3