[njs] HTTP: added strict check for js_body_filter syntax.

noreply at nginx.com noreply at nginx.com
Fri Oct 18 05:22:02 UTC 2024


details:   https://github.com/nginx/njs/commit/6ed70de1607fcf137cdfc120f68967f0bfd46829
branches:  master
commit:    6ed70de1607fcf137cdfc120f68967f0bfd46829
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu, 17 Oct 2024 18:31:26 -0700
description:
HTTP: added strict check for js_body_filter syntax.


---
 nginx/ngx_http_js_module.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index 6f026293..06429241 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -7921,20 +7921,24 @@ ngx_http_js_body_filter_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     jlcf->buffer_type = NGX_JS_STRING;
 
-    if (cf->args->nelts == 3
-         && ngx_strncmp(value[2].data, "buffer_type=", 12) == 0)
-    {
-        if (ngx_strcmp(&value[2].data[12], "string") == 0) {
-            jlcf->buffer_type = NGX_JS_STRING;
+    if (cf->args->nelts == 3) {
+        if (ngx_strncmp(value[2].data, "buffer_type=", 12) == 0) {
+            if (ngx_strcmp(&value[2].data[12], "string") == 0) {
+                jlcf->buffer_type = NGX_JS_STRING;
 
-        } else if (ngx_strcmp(&value[2].data[12], "buffer") == 0) {
-            jlcf->buffer_type = NGX_JS_BUFFER;
+            } else if (ngx_strcmp(&value[2].data[12], "buffer") == 0) {
+                jlcf->buffer_type = NGX_JS_BUFFER;
 
+            } else {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "invalid buffer_type value \"%V\", "
+                                   "it must be \"string\" or \"buffer\"",
+                                   &value[2]);
+                return NGX_CONF_ERROR;
+            }
         } else {
             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                               "invalid buffer_type value \"%V\", "
-                               "it must be \"string\" or \"buffer\"",
-                               &value[2]);
+                               "invalid parameter \"%V\"", &value[2]);
             return NGX_CONF_ERROR;
         }
     }


More information about the nginx-devel mailing list