]> git.kaiwu.me - njs.git/commitdiff
HTTP: added strict check for js_body_filter syntax.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 18 Oct 2024 01:31:26 +0000 (18:31 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 18 Oct 2024 05:21:08 +0000 (22:21 -0700)
nginx/ngx_http_js_module.c

index 6f026293999aa77c097d37a5fd5d0f05e60e16e4..0642924148f35e2e0b969cf21a33c7350a039b91 100644 (file)
@@ -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;
         }
     }