]> git.kaiwu.me - njs.git/commitdiff
HTTP: handling absence of value while iterating over r.args.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 20 Mar 2019 12:56:22 +0000 (15:56 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 20 Mar 2019 12:56:22 +0000 (15:56 +0300)
nginx/ngx_http_js_module.c

index 0705d5a8ac0069b7f3dd8a051be8675bd6dd633b..3599c9efa0a59ba5d8cdd2307bcd6469db7be587 100644 (file)
@@ -1564,7 +1564,7 @@ ngx_http_js_ext_next_arg(njs_vm_t *vm, njs_value_t *value, void *obj,
     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, njs_value_t *value, void *obj,
     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++;
+    v = ngx_strlchr(start, p, '=');
+    if (v == NULL) {
+        v = p;
+    }
 
-    p = ngx_strlchr(p, end, '&');
+    len = v - start;
 
-    if (p) {
+    if (p != end) {
         entry->data = &p[1];
         entry->len = end - entry->data;