OSDN Git Service

Merge branch 'branch_0.13.0' into branch_0.13.0-svn
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Wed, 8 Apr 2009 10:20:17 +0000 (10:20 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Wed, 8 Apr 2009 10:20:17 +0000 (10:20 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/RELEASE_0_13_0@4736 1a406e8e-add9-4483-a2c8-d8cac5b7c224

include/chxj_tag_util.h
include/mod_chxj.h
src/chxj_cookie.c
src/chxj_tag_util.c

index 41e613e..82f39ad 100644 (file)
@@ -49,6 +49,7 @@ extern char *chxj_form_action_to_hidden_tag(
   int softbank,
   chxjconvrule_entry *entryp
   );
+extern char *chxj_delete_chxj_cc_param(request_rec *r, const char *str);
 
 #endif
 /*
index 97a776a..577e677 100644 (file)
@@ -493,6 +493,8 @@ extern void chxj_dump_string(request_rec *r, const char *filename, int line, con
 extern void *rpl_malloc(size_t n);
 #endif
 
+
+#define TO_ADDR(X) ((unsigned int)(apr_size_t)(X))
 #endif
 /*
  * vim:ts=2 et
index c95f6cb..5f725b9 100644 (file)
@@ -159,7 +159,7 @@ chxj_save_cookie(request_rec *r)
 
   for (ii=0; ii<headers->nelts; ii++) {
     if (strcasecmp(hentryp[ii].key, "Set-Cookie") == 0) {
-      DBG(r, "REQ[%X] cookie=[%s:%s]", (unsigned int)(apr_size_t)r, hentryp[ii].key, hentryp[ii].val);
+      DBG(r, "REQ[%X] cookie=[%s:%s]", TO_ADDR(r), hentryp[ii].key, hentryp[ii].val);
 
       char* key;
       char* val;
@@ -181,7 +181,7 @@ chxj_save_cookie(request_rec *r)
   }
   for (ii=0; ii<err_headers->nelts; ii++) {
     if (strcasecmp(err_hentryp[ii].key, "Set-Cookie") == 0) {
-      DBG(r, "REQ[%X] cookie=[%s:%s]", (unsigned int)(apr_size_t)r, err_hentryp[ii].key, err_hentryp[ii].val);
+      DBG(r, "REQ[%X] cookie=[%s:%s]", TO_ADDR(r), err_hentryp[ii].key, err_hentryp[ii].val);
 
       char* key;
       char* val;
@@ -809,7 +809,7 @@ chxj_add_cookie_parameter(request_rec *r, char *value, cookie_t *cookie)
   char *dst;
   char *name = "";
 
-  DBG(r, "start chxj_add_cookie_parameter() cookie_id=[%s]", (cookie) ? cookie->cookie_id : NULL);
+  DBG(r, "REQ[%X] start chxj_add_cookie_parameter() cookie_id=[%s]", TO_ADDR(r), (cookie) ? cookie->cookie_id : NULL);
 
   dst = apr_pstrdup(r->pool, value);
 
@@ -820,7 +820,7 @@ chxj_add_cookie_parameter(request_rec *r, char *value, cookie_t *cookie)
     goto on_error;
 
   if (chxj_cookie_check_host(r, value) != 0) {
-    DBG(r, "end chxj_add_cookie_parameter()(check host)");
+    DBG(r, "REQ[%X] end chxj_add_cookie_parameter()(check host)", TO_ADDR(r));
     goto on_error;
   }
 
@@ -832,18 +832,27 @@ chxj_add_cookie_parameter(request_rec *r, char *value, cookie_t *cookie)
 
   qs = strchr(dst, '?');
   if (qs) {
+    char *sv_qs = qs;
+    qs = chxj_delete_chxj_cc_param(r, ++qs);
+    DBG(r, "REQ[%X] qs:[%s]",TO_ADDR(r), qs);
+    *sv_qs = 0;
+    if (qs && strlen(qs)) {
+      dst = apr_psprintf(r->pool, "%s?%s", dst, qs);
+    }
+  }
+  if (qs) {
     dst = apr_psprintf(r->pool, "%s&%s=%s%s", dst, CHXJ_COOKIE_PARAM, cookie->cookie_id, name);
   }
   else {
     dst = apr_psprintf(r->pool, "%s?%s=%s%s", dst, CHXJ_COOKIE_PARAM, cookie->cookie_id, name);
   }
 
-  DBG(r, "end   chxj_add_cookie_parameter() dst=[%s]", dst);
+  DBG(r, "REQ[%X] end   chxj_add_cookie_parameter() dst=[%s]", TO_ADDR(r), dst);
 
   return dst;
 
 on_error:
-  DBG(r, "end   chxj_add_cookie_parameter() (on_error)");
+  DBG(r, "REQ[%X] end   chxj_add_cookie_parameter() (on_error)", TO_ADDR(r));
   return dst;
 }
 
index de6989a..2a1f034 100644 (file)
@@ -18,6 +18,7 @@
 #include "chxj_url_encode.h"
 #include "chxj_str_util.h"
 #include "chxj_jreserved_tag.h"
+#include "mod_chxj.h"
 
 
 /**
@@ -687,6 +688,57 @@ chxj_form_action_to_hidden_tag(
   }
   return result;
 }
+
+
+char *
+chxj_delete_chxj_cc_param(
+  request_rec         *r,
+  const char          *str)
+{
+  apr_pool_t  *pool;
+  char        *s;
+  int         xmlFlag = 0;
+
+  DBG(r, "REQ[%X] start chxj_delete_chxj_cc_param() str:[%s]", TO_ADDR(r),str);
+
+  apr_pool_create(&pool, r->pool);
+  s = apr_pstrdup(pool, str);
+
+  if (!s) {
+    DBG(r, "REQ[%X] end chxj_delete_chxj_cc_param() Memory Allocation Error", TO_ADDR(r));
+    return NULL;
+  }
+  char *result = NULL;
+
+  char *pstat;
+  char *pstat2;
+  for (;;) {
+    char *pair = apr_strtok(s, "&", &pstat);
+    if (! pair) break;
+    if (strncasecmp(pair, "amp;", 4) == 0) {
+      pair += 4;
+      xmlFlag = 1;
+    }
+    s = NULL;
+    char *key = apr_strtok(pair, "=",  &pstat2);
+    char *val = "";
+    if (key) {
+      val = apr_strtok(NULL, "=", &pstat2);
+      if (!val) val = "";
+    }
+    if (strcasecmp(key, "_chxj_cc")) {
+      if (result) {
+        result = apr_pstrcat(pool, result, ((xmlFlag) ? "&amp;" : "&"), key, "=", val, NULL);
+      }
+      else {
+        result = apr_pstrcat(pool, key, "=", val, NULL);
+      }
+    }
+  }
+  DBG(r, "REQ[%X] result:[%s]", TO_ADDR(r), result);
+  DBG(r, "REQ[%X] end chxj_delete_chxj_cc_param() ", TO_ADDR(r));
+  return result;
+}
 /*
  * vim:ts=2 et
  */