Skip to content

Commit

Permalink
fixed a bug about null string when using quote_sql_str
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimp committed Sep 1, 2010
1 parent d7bbef3 commit e7c6c16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/ngx_http_set_quote_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ngx_http_set_misc_quote_pgsql_str(ngx_http_request_t *r,
ngx_int_t length;

if (v->not_found || v->len ==0) {
res->data = (u_char *) "null";
res->len = sizeof("null") - 1;
res->data = (u_char *) "''";
res->len = sizeof("''") - 1;
return NGX_OK;
}

Expand Down Expand Up @@ -186,8 +186,8 @@ ngx_http_set_misc_quote_sql_str(ngx_http_request_t *r,
size_t escape;

if (v->not_found || v->len == 0) {
res->data = (u_char *) "null";
res->len = sizeof("null") - 1;
res->data = (u_char *) "''";
res->len = sizeof("''") - 1;
return NGX_OK;
}

Expand Down
12 changes: 8 additions & 4 deletions test/t/quote-sql.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ run_tests();

__DATA__
=== TEST 1: set quote sql value
--- config
location /foo {
Expand All @@ -29,6 +28,7 @@ GET /foo
'hello\n\r\'\"\\'
=== TEST 2: set quote sql value (in place)
--- config
location /foo {
Expand All @@ -53,7 +53,7 @@ GET /foo
--- request
GET /foo
--- response_body
null
''
Expand All @@ -66,7 +66,8 @@ null
--- request
GET /foo
--- response_body
null
''
=== TEST 5: set quote null pgsql value
Expand All @@ -78,7 +79,8 @@ null
--- request
GET /foo
--- response_body
null
''
=== TEST 6: set quote pgsql value
Expand All @@ -94,6 +96,7 @@ GET /foo
E'hello\n\r\'\"\\'
=== TEST 7: set quote pgsql valid utf8 value
--- config
location /foo {
Expand All @@ -107,6 +110,7 @@ GET /foo
E'你好'
=== TEST 8: set quote pgsql invalid utf8 value
--- config
location /foo {
Expand Down

0 comments on commit e7c6c16

Please sign in to comment.