]> granicus.if.org Git - apache/commitdiff
mod_lua: Use ap_cookie_read for reading cookie values, since it's already there.
authorDaniel Gruno <humbedooh@apache.org>
Thu, 5 Sep 2013 08:23:05 +0000 (08:23 +0000)
committerDaniel Gruno <humbedooh@apache.org>
Thu, 5 Sep 2013 08:23:05 +0000 (08:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1520248 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/lua_request.c

index 220bfbaf35dc1e27b143984b2ee96238a5728bae..6f43da5c36cc1d99e6827d7127047d80d6c24b43 100644 (file)
@@ -27,6 +27,7 @@
 #include "apr_pools.h"
 #include "apr_thread_mutex.h"
 #include "apr_tables.h"
+#include "util_cookies.h"
 
 #include <lua.h>
 
@@ -1891,15 +1892,12 @@ static int lua_ivm_set(lua_State *L)
 
 static int lua_get_cookie(lua_State *L) 
 {
-    const char *key, *cookies, *pattern;
-    char *cookie;
+    int n;
+    const char *key, *cookie;
     request_rec *r = ap_lua_check_request_rec(L, 1);
     key = luaL_checkstring(L, 2);
-    cookie = apr_pcalloc(r->pool, 256);
-    cookies = apr_table_get(r->headers_in, "Cookie");
-    pattern = apr_psprintf(r->pool, "%s=%%255[^;]", key);
-    sscanf(cookies, pattern, cookie);
-    if (strlen(cookie) > 0) {
+    ap_cookie_read(r, key, &cookie, 0);
+    if (cookie != NULL) {
         lua_pushstring(L, cookie);
         return 1;
     }