ngx.req.get_post_args Issue

Nginx User nginx at nginxuser.net
Sat Nov 5 16:04:41 UTC 2011


-************************
           START
-************************
if ngx.var.request_method == "POST" then
	ngx.req.read_body()
	local post_args = ngx.req.get_post_args()
	for my_key, v in pairs( post_args ) do
		if type(v) == "table" then
			my_arg = table.concat(v, " ")
		else
			my_arg = v
		end
		regex_rules.log_alert("Alert:- " .. my_key .. " ::: " .. my_arg)
	end
end
-************************
           END
-************************


The code in ngx_lua below which should log key/value pairs from a post
request results in the log output below:


-************************
           START
-************************
[alert] 17670#0: *1 Alert:- app_form[localServerPath] :::
/home/user/testsite.com/public_html/share/data/505
/home/user/testsite.com/public_html/share/data/505, client:
89.148.6.249, server: testsite.com, request: "POST // HTTP/1.1", host:
"testsite.com", referrer:
"http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"

[alert] 17670#0: *1 Alert:- app_form[formName] ::: ItemAddFromServer
ItemAddFromServer, client: 89.148.6.249, server: testsite.com,
request: "POST // HTTP/1.1", host: "testsite.com", referrer:
"http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"
[debug] 17670#0: *1 posix_memalign: 08A6A910:4096 @16

[alert] 17670#0: *1 Alert:- app_itemId ::: 470
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_formUrl"

//?app_view=core.ItemAdmin 470
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_authToken"

8845e98e9296
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_controller"

core.ItemAdd
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_form[formName]"

ItemAddFromServer
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_itemId"

470
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_addPlugin"

ItemAddFromServer
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_form[localServerPath]"

/home/user/testsite.com/public_html/share/data/505
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_form[set][title]"

on
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data;
name="app_form[CreateThumbnailOption][createThumbnail]"

on
------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name="app_form[action][addFromLocalServer]"

Add Files
------WebKitFormBoundary3c6CizwarDCoyCst--
, client: 89.148.6.249, server: testsite.com, request: "POST //
HTTP/1.1", host: "testsite.com", referrer:
"http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"

[alert] 17670#0: *1 Alert:- app_form[action][findFilesFromLocalServer]
::: 1 1, client: 89.148.6.249, server: testsite.com, request: "POST //
HTTP/1.1", host: "testsite.com", referrer:
"http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"

[alert] 17670#0: *1 Alert:- ------WebKitFormBoundary3c6CizwarDCoyCst
Content-Disposition: form-data; name ::: "app_return"

//?app_view=core.ItemAdmin, client: 89.148.6.249, server:
testsite.com, request: "POST // HTTP/1.1", host: "testsite.com",
referrer: "http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"

[alert] 17670#0: *1 Alert:- app_subView ::: core.ItemAdd core.ItemAdd,
client: 89.148.6.249, server: testsite.com, request: "POST //
HTTP/1.1", host: "testsite.com", referrer:
"http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"

[alert] 17670#0: *1 Alert:- app_addPlugin ::: ItemAddFromServer
ItemAddFromServer, client: 89.148.6.249, server: testsite.com,
request: "POST // HTTP/1.1", host: "testsite.com", referrer:
"http://testsite.com/?app_view=core.ItemAdmin&app_subView=core.ItemAdd&app_addPlugin=ItemAddFromServer&app_form%5BlocalServerPath%5D=/home/user/testsite.com/public_html/share/data/505&app_itemId=470&app_form%5Baction%5D%5BfindFilesFromLocalServer%5D=1&app_form%5BformName%5D=ItemAddFromServer"
-************************
           END
-************************


1. The concat command suggests that when "v" is a table, the table
holds the same value twice. E.G. "[alert] 17670#0: *1 Alert:-
app_form[action][findFilesFromLocalServer] ::: 1 1," and "[alert]
17670#0: *1 Alert:- app_form[localServerPath] :::
/home/user/testsite.com/public_html/share/data/505
/home/user/testsite.com/public_html/share/data/505,"

2. The "------WebKitFormBoundary3c6CizwarDCoyCst" lines seem to
suggest the request body has been somehow attached to one of the
variables "app_itemId". This should just have a value of 140.


I have posted the form that generates this at:
http://pastebin.com/6scK6cWP. (Pls widen page view to see properly)

Thanks



More information about the nginx mailing list