Permalink
Browse files

fixed a bug about null string when using quote_sql_str

  • Loading branch information...
1 parent d7bbef3 commit e7c6c167ea0713e3d5c2a351f7d761013f0a0370 @shrimp shrimp committed Sep 1, 2010
Showing with 12 additions and 8 deletions.
  1. +4 −4 src/ngx_http_set_quote_sql.c
  2. +8 −4 test/t/quote-sql.t
@@ -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;
}
@@ -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;
}
View
@@ -15,7 +15,6 @@ run_tests();
__DATA__
-
=== TEST 1: set quote sql value
--- config
location /foo {
@@ -29,6 +28,7 @@ GET /foo
'hello\n\r\'\"\\'
+
=== TEST 2: set quote sql value (in place)
--- config
location /foo {
@@ -53,7 +53,7 @@ GET /foo
--- request
GET /foo
--- response_body
-null
+''
@@ -66,7 +66,8 @@ null
--- request
GET /foo
--- response_body
-null
+''
+
=== TEST 5: set quote null pgsql value
@@ -78,7 +79,8 @@ null
--- request
GET /foo
--- response_body
-null
+''
+
=== TEST 6: set quote pgsql value
@@ -94,6 +96,7 @@ GET /foo
E'hello\n\r\'\"\\'
+
=== TEST 7: set quote pgsql valid utf8 value
--- config
location /foo {
@@ -107,6 +110,7 @@ GET /foo
E'你好'
+
=== TEST 8: set quote pgsql invalid utf8 value
--- config
location /foo {

0 comments on commit e7c6c16

Please sign in to comment.