[njs] HTTP: handling absence of value while iterating over r.args.

Dmitry Volyntsev xeioex at nginx.com
Wed Mar 20 12:59:34 UTC 2019


details:   https://hg.nginx.org/njs/rev/64dc0795c2f0
branches:  
changeset: 836:64dc0795c2f0
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Mar 20 15:56:22 2019 +0300
description:
HTTP: handling absence of value while iterating over r.args.

diffstat:

 nginx/ngx_http_js_module.c |  20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (40 lines):

diff -r 04032d0970b4 -r 64dc0795c2f0 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Tue Mar 19 18:26:44 2019 +0300
+++ b/nginx/ngx_http_js_module.c	Wed Mar 20 15:56:22 2019 +0300
@@ -1564,7 +1564,7 @@ ngx_http_js_ext_next_arg(njs_vm_t *vm, n
     ngx_str_t **e = next;
 
     size_t      len;
-    u_char     *p, *start, *end;
+    u_char     *v, *p, *start, *end;
     ngx_str_t  *entry;
 
     entry = *e;
@@ -1576,17 +1576,19 @@ ngx_http_js_ext_next_arg(njs_vm_t *vm, n
     start = entry->data;
     end = start + entry->len;
 
-    p = ngx_strlchr(start, end, '=');
+    p = ngx_strlchr(start, end, '&');
     if (p == NULL) {
-        return NJS_ERROR;
+        p = end;
     }
 
-    len = p - start;
-    p++;
-
-    p = ngx_strlchr(p, end, '&');
-
-    if (p) {
+    v = ngx_strlchr(start, p, '=');
+    if (v == NULL) {
+        v = p;
+    }
+
+    len = v - start;
+
+    if (p != end) {
         entry->data = &p[1];
         entry->len = end - entry->data;
 


More information about the nginx-devel mailing list