Permalink
Browse files

fixed a bug in empty value lists.

  • Loading branch information...
1 parent 5ba87a9 commit 6431ba5742ff81e62c11311b3c253a9d531f025a @agentzh agentzh committed Feb 12, 2010
Showing with 26 additions and 11 deletions.
  1. +9 −9 src/ngx_http_array_var_module.c
  2. +17 −2 test/t/sanity.t
@@ -389,18 +389,18 @@ ngx_http_array_var_split(ngx_http_request_t *r,
pos = last + sep->len;
}
- if (pos < end) {
- s = ngx_array_push(array);
- if (s == NULL) {
- return NGX_ERROR;
- }
-
- s->data = pos;
- s->len = end - pos;
+ dd("pos %p, last %p, end %p", pos, last, end);
- dd("split item %.*s", s->len, s->data);
+ s = ngx_array_push(array);
+ if (s == NULL) {
+ return NGX_ERROR;
}
+ s->data = pos;
+ s->len = end - pos;
+
+ dd("split item %.*s", s->len, s->data);
+
dd("split: array size: %d", array->nelts);
dd("split array ptr: %p", array);
View
@@ -3,7 +3,8 @@
use lib 'lib';
use Test::Nginx::Socket;
-repeat_each(3);
+#repeat_each(3);
+repeat_each(1);
plan tests => repeat_each() * 2 * blocks();
@@ -43,7 +44,7 @@ nomas
-=== TEST 3: array split/join (empty)
+=== TEST 3: array split/join (empty array)
--- config
location /foo {
array_split ',' $arg_names to=$names;
@@ -55,3 +56,17 @@ GET /foo?
--- response_body
[]
+
+
+=== TEST 4: array split/join (list of empty values)
+--- config
+ location /foo {
+ array_split ',' $arg_names to=$names;
+ array_join '+' $names;
+ echo "[$names]";
+ }
+--- request
+GET /foo?names=,,,
+--- response_body
+[+++]
+

0 comments on commit 6431ba5

Please sign in to comment.