[nginx] Script: changed index and try_files to evaluate lengths ...
Maxim Dounin
mdounin at mdounin.ru
Sat Jul 25 00:04:55 UTC 2026
details: http://freenginx.org/hg/nginx/rev/1260ebda7574
branches:
changeset: 9580:1260ebda7574
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sun Jul 19 03:13:01 2026 +0300
description:
Script: changed index and try_files to evaluate lengths twice.
Similarly to changes introduced to ngx_http_script_run(), direct script
evaluation in index and try_files now uses a separate length calculation
loop without e.flushed to ensure that all relevant non-cacheable
variables are flushed, and also to look up all the values. This resolves
issues observed with non-cacheable variables and variables with side
effects in the index and try_files directives.
diffstat:
src/http/modules/ngx_http_index_module.c | 8 ++++++++
src/http/modules/ngx_http_try_files_module.c | 8 ++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diffs (36 lines):
diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -150,6 +150,14 @@ ngx_http_index_handler(ngx_http_request_
e.ip = index[i].lengths->elts;
e.request = r;
+ while (*(uintptr_t *) e.ip) {
+ lcode = *(ngx_http_script_len_code_pt *) e.ip;
+ (void) lcode(&e);
+ }
+
+ e.ip = index[i].lengths->elts;
+ e.flushed = 1;
+
/* 1 is for terminating '\0' as in static names */
len = 1;
diff --git a/src/http/modules/ngx_http_try_files_module.c b/src/http/modules/ngx_http_try_files_module.c
--- a/src/http/modules/ngx_http_try_files_module.c
+++ b/src/http/modules/ngx_http_try_files_module.c
@@ -123,6 +123,14 @@ ngx_http_try_files_handler(ngx_http_requ
e.ip = tf->lengths->elts;
e.request = r;
+ while (*(uintptr_t *) e.ip) {
+ lcode = *(ngx_http_script_len_code_pt *) e.ip;
+ (void) lcode(&e);
+ }
+
+ e.ip = tf->lengths->elts;
+ e.flushed = 1;
+
/* 1 is for terminating '\0' as in static names */
len = 1;
More information about the nginx-devel
mailing list