diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2023-05-26 19:13:39 -0700 |
---|---|---|
committer | Dmitry Volyntsev <xeioex@nginx.com> | 2023-05-26 19:13:39 -0700 |
commit | 0407ae2c22f9d34117a94c20d70faae5cf40195d (patch) | |
tree | fd1c31e48723675d22d44eced48d6a483a1e21ce /nginx/ngx_http_js_module.c | |
parent | 1a2a65f7d18aa7e45ef763d2f2457350f30b1da2 (diff) | |
download | njs-0407ae2c22f9d34117a94c20d70faae5cf40195d.tar.gz njs-0407ae2c22f9d34117a94c20d70faae5cf40195d.zip |
HTTP: throwing an exception in r.internalRedirect() while filtering.
A user is notified explicitly that r.internalRedirect()
is not supported in filters.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r-- | nginx/ngx_http_js_module.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index e2fda66d..44abddc2 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -950,6 +950,7 @@ ngx_http_js_header_filter(ngx_http_request_t *r) ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); + ctx->filter = 1; pending = njs_vm_pending(ctx->vm); rc = ngx_js_call(ctx->vm, &jlcf->header_filter, r->connection->log, @@ -2433,6 +2434,11 @@ ngx_http_js_ext_internal_redirect(njs_vm_t *vm, njs_value_t *args, ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); + if (ctx->filter) { + njs_vm_error(vm, "internalRedirect cannot be called while filtering"); + return NJS_ERROR; + } + if (ngx_js_string(vm, njs_arg(args, nargs, 1), &uri) != NGX_OK) { njs_vm_error(vm, "failed to convert uri arg"); return NJS_ERROR; |