Skip to content

Commit fae3d85

Browse files
committed
docs: added new section "SQL Literal Quoting".
1 parent 7bf190e commit fae3d85

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.markdown

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ Sets whether to use the "compact-arrays" structure for the resultsets returned b
255255

256256
This method was first introduced in the `v0.09` release.
257257

258+
SQL Literal Quoting
259+
===================
260+
261+
It is always important to quote SQL literals properly to prevent SQL injection attacks. You can use the
262+
[ngx.quote_sql_str](http://wiki.nginx.org/HttpLuaModule#ngx.quote_sql_str) function provided by ngx_lua to quote values.
263+
Here is an example:
264+
265+
local name = ngx.unescape_uri(ngx.var.arg_name)
266+
local quoted_name = ngx.quote_sql_str(name)
267+
local sql = "select * from users where name = " .. name
268+
258269
Debugging
259270
=========
260271

0 commit comments

Comments
 (0)