httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1365539 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS modules/lua/lua_request.c modules/lua/mod_lua.h
Date Wed, 25 Jul 2012 11:50:06 GMT
Author: jim
Date: Wed Jul 25 11:50:06 2012
New Revision: 1365539

URL: http://svn.apache.org/viewvc?rev=1365539&view=rev
Log:
Merge r1352047, r1361298 from trunk:

Add the missing parsebody function to mod_lua, for parsing POST data.
PR 53064.

- Define LUA_COMPAT_ALL so mod_lua will be compatible with Lua 5.2
- Add an optional integer argument for parsebody, specifying the maximum size of POST that
will be accepted.
Submitted by: humbedooh
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/modules/lua/lua_request.c
    httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1352047,1361298

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1365539&r1=1365538&r2=1365539&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Wed Jul 25 11:50:06 2012
@@ -7,6 +7,9 @@ Changes with Apache 2.4.3
      possible XSS for a site where untrusted users can upload files to
      a location with MultiViews enabled. [Niels Heinen <heinenn google.com>]
 
+  *) mod_lua: Add the parsebody function for parsing POST data. PR 53064.
+     [Daniel Gruno]
+
   *) apxs: Use LDFLAGS from config_vars.mk in addition to CFLAGS and CPPFLAGS.
      [Stefan Fritsch]
 

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1365539&r1=1365538&r2=1365539&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Wed Jul 25 11:50:06 2012
@@ -88,14 +88,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_lua: - Add a parsebody function for retrieving POST data. PR: 53064
-              - Make mod_lua compatible with Lua 5.2
-     Trunk patch:
-       http://svn.apache.org/viewvc?view=revision&revision=1352047 and
-       http://svn.apache.org/viewvc?view=revision&revision=1361298
-     2.4.x patch:
-       http://www.humbedooh.com/mods/mod_lua.patch (+CHANGES)
-     +1: humbedooh, rjung, jim
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:

Modified: httpd/httpd/branches/2.4.x/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/lua_request.c?rev=1365539&r1=1365538&r2=1365539&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/lua_request.c (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/lua_request.c Wed Jul 25 11:50:06 2012
@@ -164,6 +164,34 @@ static int req_parseargs(lua_State *L)
     return 2;                   /* [table<string, string>, table<string, array<string>>]
*/
 }
 
+/* r:parsebody() returning a lua table */
+static int req_parsebody(lua_State *L)
+{
+    apr_array_header_t          *pairs;
+    apr_off_t len;
+    int res;
+    apr_size_t size;
+    apr_size_t max_post_size;
+    char *buffer;
+    request_rec *r = ap_lua_check_request_rec(L, 1);
+    max_post_size = (apr_size_t) luaL_optint(L, 2, MAX_STRING_LEN);
+    lua_newtable(L);
+    lua_newtable(L);            /* [table, table] */
+    res = ap_parse_form_data(r, NULL, &pairs, -1, max_post_size);
+    if (res == OK) {
+        while(pairs && !apr_is_empty_array(pairs)) {
+            ap_form_pair_t *pair = (ap_form_pair_t *) apr_array_pop(pairs);
+            apr_brigade_length(pair->value, 1, &len);
+            size = (apr_size_t) len;
+            buffer = apr_palloc(r->pool, size + 1);
+            apr_brigade_flatten(pair->value, buffer, &size);
+            buffer[len] = 0;
+            req_aprtable2luatable_cb(L, pair->name, buffer);
+        }
+    }
+    return 2;                   /* [table<string, string>, table<string, array<string>>]
*/
+}
+
 /* wrap ap_rputs as r:puts(String) */
 static int req_puts(lua_State *L)
 {
@@ -610,6 +638,8 @@ AP_LUA_DECLARE(void) ap_lua_load_request
                  makefun(&req_document_root, APL_REQ_FUNTYPE_STRING, p));
     apr_hash_set(dispatch, "parseargs", APR_HASH_KEY_STRING,
                  makefun(&req_parseargs, APL_REQ_FUNTYPE_LUACFUN, p));
+    apr_hash_set(dispatch, "parsebody", APR_HASH_KEY_STRING,
+                 makefun(&req_parsebody, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "debug", APR_HASH_KEY_STRING,
                  makefun(&req_debug, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "info", APR_HASH_KEY_STRING,

Modified: httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h?rev=1365539&r1=1365538&r2=1365539&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h Wed Jul 25 11:50:06 2012
@@ -44,6 +44,8 @@
 #include "lauxlib.h"
 #include "lualib.h"
 
+/* Allow for Lua 5.2 backwards compatibility */
+#define LUA_COMPAT_ALL
 #if LUA_VERSION_NUM > 501
 /* Load mode for lua_load() */
 #define lua_load(a,b,c,d) lua_load(a,b,c,d,NULL)



Mime
View raw message