OSDN Git Service

* Fixed Bug.
authorAtsushi Konno <konn@users.sourceforge.jp>
Thu, 10 Mar 2011 13:28:25 +0000 (22:28 +0900)
committerAtsushi Konno <konn@users.sourceforge.jp>
Thu, 10 Mar 2011 13:28:25 +0000 (22:28 +0900)
    - not convert image if ``ChxjImageEngine On'' is set without
      ``ChxjConvRule EngineOn''.

src/mod_chxj.c

index a3f5ae0..f71a661 100644 (file)
@@ -229,39 +229,42 @@ chxj_headers_fixup(request_rec *r)
   case CHXJ_SPEC_Jhtml:
   case CHXJ_SPEC_Jxhtml:
     entryp = chxj_apply_convrule(r, dconf->convrules);
-    if (! entryp) {
-      DBG(r, "REQ[%X] end %s() (no pattern)", TO_ADDR(r),__func__);
-      return DECLINED;
-    }
-    if (!(entryp->action & CONVRULE_ENGINE_ON_BIT) && !(entryp->action & CONVRULE_COOKIE_ONLY_BIT)) {
-      DBG(r, "REQ[%X] end %s() (engine off)", TO_ADDR(r),__func__);
-      return DECLINED;
-    }
-    if (entryp->action & CONVRULE_EMOJI_ONLY_BIT) {
-      DBG(r, "REQ[%X] end %s() (emoji only)", TO_ADDR(r),__func__);
-      return DECLINED;
+    if (dconf->image != CHXJ_IMG_ON) {
+      if (! entryp) {
+        DBG(r, "REQ[%X] end %s() (no pattern)", TO_ADDR(r), __func__);
+        return DECLINED;
+      }
+      if (!(entryp->action & CONVRULE_ENGINE_ON_BIT) && !(entryp->action & CONVRULE_COOKIE_ONLY_BIT)) {
+        DBG(r, "REQ[%X] end %s() (engine off)", TO_ADDR(r), __func__);
+        return DECLINED;
+      }
+      if (entryp->action & CONVRULE_EMOJI_ONLY_BIT) {
+        DBG(r, "REQ[%X] end %s() (emoji only)", TO_ADDR(r), __func__);
+        return DECLINED;
+      } 
     } 
-  
     apr_table_setn(r->headers_in, 
                    CHXJ_HTTP_USER_AGENT, 
                    user_agent);
   
-    if (entryp->user_agent)
+    if (entryp && entryp->user_agent)
       apr_table_setn(r->headers_in, 
                      HTTP_USER_AGENT, 
                      entryp->user_agent);
     /*
      * this clear process must do before chxj_convert_input_header function.
      */
-    if ((entryp->action & CONVRULE_COOKIE_ON_BIT) || (entryp->action & CONVRULE_COOKIE_ONLY_BIT)) {
-      if (r->method_number == M_POST) {
-        if (! apr_table_get(r->headers_in, "X-Chxj-Forward")) {
+    if (entryp) {
+      if ((entryp->action & CONVRULE_COOKIE_ON_BIT) || (entryp->action & CONVRULE_COOKIE_ONLY_BIT)) {
+        if (r->method_number == M_POST) {
+          if (! apr_table_get(r->headers_in, "X-Chxj-Forward")) {
+            s_clear_cookie_header(r, spec);
+          }
+        }
+        else {
           s_clear_cookie_header(r, spec);
         }
       }
-      else {
-        s_clear_cookie_header(r, spec);
-      }
     }
 
     chxj_convert_input_header(r,entryp, spec);
@@ -317,7 +320,7 @@ chxj_headers_fixup(request_rec *r)
         if (strcmp(addr, r->connection->remote_ip) == 0) {
           r->connection->remote_ip = apr_pstrdup(r->connection->pool, client_ip);
           /* For mod_cidr_lookup */
-          if (entryp->action & CONVRULE_OVERWRITE_X_CLIENT_TYPE_BIT) {
+          if (entryp && (entryp->action & CONVRULE_OVERWRITE_X_CLIENT_TYPE_BIT)) {
             char *client_type = (char *)apr_table_get(r->headers_in, CHXJ_HEADER_ORIG_CLIENT_TYPE);
             DBG(r, "REQ[%X] Overwrite X-Client-Type to [%s]", TO_ADDR(r), client_type);
             if (client_type) {
@@ -704,7 +707,7 @@ chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp, device_tabl
       if (strlen(result) != 0) 
         result = apr_pstrcat(r->pool, result, "&", NULL);
 
-      if (strcasecmp(entryp->encoding, "NONE") != 0) {
+      if (entryp && strcasecmp(entryp->encoding, "NONE") != 0) {
         apr_size_t dlen;
         char *dvalue;
         char *dname;
@@ -926,7 +929,7 @@ chxj_input_convert(
       if (strlen(result) != 0)
         result = apr_pstrcat(pool, result, "&", NULL);
 
-      if (strcasecmp(entryp->encoding, "NONE") != 0 && value && strlen(value)) {
+      if (entryp && strcasecmp(entryp->encoding, "NONE") != 0 && value && strlen(value)) {
         apr_size_t dlen;
         char       *dvalue;
 
@@ -1063,7 +1066,7 @@ pass_data_to_filter(ap_filter_t *f, const char *data,
 static void
 s_add_no_cache_headers(request_rec *r, chxjconvrule_entry  *entryp)
 {
-  if (entryp->action & CONVRULE_NOCACHE_ON_BIT) {
+  if (entryp && (entryp->action & CONVRULE_NOCACHE_ON_BIT)) {
     apr_table_unset(r->headers_out,     "Pragma");
     apr_table_unset(r->err_headers_out, "Pragma");
     apr_table_unset(r->headers_out,     "Expires");
@@ -1763,7 +1766,8 @@ chxj_insert_filter(request_rec *r)
     spec = req_conf->spec;
   }
   entryp = chxj_apply_convrule(r, dconf->convrules);
-  if (!entryp) {
+  if (!entryp && dconf->image != CHXJ_IMG_ON) {
+    DBG(r, "REQ[%X] entryp is NULL and ChxjImageEngine Off", TO_ADDR(r));
     DBG(r, "REQ[%X] end %s()", TO_ADDR(r),__func__);
     return;
   }
@@ -1779,12 +1783,11 @@ chxj_insert_filter(request_rec *r)
   ctx->buffer = apr_palloc(ctx->pool, 1);
   ctx->buffer[0] = 0;
 
-  if (!entryp || (!(entryp->action & CONVRULE_ENGINE_ON_BIT) && !(entryp->action & CONVRULE_COOKIE_ONLY_BIT))) {
-    DBG(r,"REQ[%X] EngineOff", TO_ADDR(r));
-    DBG(r, "REQ[%X] end %s()", TO_ADDR(r),__func__);
+  if (dconf->image != CHXJ_IMG_ON && (!entryp || (!(entryp->action & CONVRULE_ENGINE_ON_BIT) && !(entryp->action & CONVRULE_COOKIE_ONLY_BIT)))) {
+    DBG(r,"REQ[%X] EngineOff and ChxjImageEngine Off", TO_ADDR(r));
+    DBG(r,"REQ[%X] end %s()", TO_ADDR(r),__func__);
     return;
   }
-
   switch(spec->html_spec_type) {
   case CHXJ_SPEC_Chtml_1_0:
   case CHXJ_SPEC_Chtml_2_0: