]> git.kaiwu.me - njs.git/commitdiff
HTTP: throwing an exception in internalRedirect() for a subrequest.
authorAlexander Borisov <alexander.borisov@nginx.com>
Thu, 8 Oct 2020 15:47:04 +0000 (18:47 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Thu, 8 Oct 2020 15:47:04 +0000 (18:47 +0300)
This closes #214 issue on GitHub.

nginx/ngx_http_js_module.c

index e9132fd8baf4ff45c4fbfcdec3082f28f904652a..4e2f007739b47a950d94ae0b6a669059c58c756d 100644 (file)
@@ -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) {