From: konn Date: Fri, 14 Mar 2008 08:12:23 +0000 (+0000) Subject: * X-Git-Tag: v0.14.1~308 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c832e402aa7ae3a01c3a36e72ee9e38d175365c5;p=modchxj%2Fmod_chxj.git * git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/trunk@1875 1a406e8e-add9-4483-a2c8-d8cac5b7c224 --- diff --git a/include/mod_chxj.h b/include/mod_chxj.h index 826d8033..0664e470 100644 --- a/include/mod_chxj.h +++ b/include/mod_chxj.h @@ -368,6 +368,7 @@ typedef struct { #define CHXJ_MOD_CONFIG_KEY "chxj_module_key" #define HTTP_USER_AGENT "User-Agent" +#define HTTP_CONTENT_LENGTH "Content-Length" #define CHXJ_HTTP_USER_AGENT "CHXJ_HTTP_USER_AGENT" module AP_MODULE_DECLARE_DATA chxj_module; diff --git a/src/chxj_emoji.c b/src/chxj_emoji.c index b4f30dcb..2b19845d 100644 --- a/src/chxj_emoji.c +++ b/src/chxj_emoji.c @@ -548,14 +548,12 @@ dbg_r = r; } DBG(r, "NOT FOUND EMOJI"); } - if ( ((0x81 <= (unsigned char)src[i]) - && (0x9f >= (unsigned char)src[i]) - && (0x40 <= (unsigned char)src[i+1]) - && (0x7e >= (unsigned char)src[i+1])) - ||((0xe0 <= (unsigned char)src[i]) - && (0xfc >= (unsigned char)src[i]) - && (0x80 <= (unsigned char)src[i+1]) - && (0xfc >= (unsigned char)src[i+1]))) { + if ( ( ((0x81 <= (unsigned char)src[i]) && (0x9f >= (unsigned char)src[i])) + ||((0xe0 <= (unsigned char)src[i]) && (0xfc >= (unsigned char)src[i])) + ) + && + ( ((0x40 <= (unsigned char)src[i+1]) && (0x7e >= (unsigned char)src[i+1])) + ||((0x80 <= (unsigned char)src[i+1]) && (0xfc >= (unsigned char)src[i+1])))) { /* SJIS MultiByte */ mb[0] = src[i++]; mb[1] = src[i]; diff --git a/src/mod_chxj.c b/src/mod_chxj.c index cf5ab1f5..0e497cda 100644 --- a/src/mod_chxj.c +++ b/src/mod_chxj.c @@ -142,11 +142,13 @@ chxj_headers_fixup(request_rec *r) chxjconvrule_entry *entryp; char *user_agent; device_table *spec; + char *content_length; + char *content_type; DBG(r, "start chxj_headers_fixup()"); dconf = ap_get_module_config(r->per_dir_config, &chxj_module); - user_agent = (char*)apr_table_get(r->headers_in, HTTP_USER_AGENT); + user_agent = (char*)apr_table_get(r->headers_in, HTTP_USER_AGENT); spec = chxj_specified_device(r, user_agent); switch(GET_HTML_SPEC_TYPE(spec)) { @@ -176,6 +178,24 @@ chxj_headers_fixup(request_rec *r) entryp->user_agent); chxj_convert_input_header(r,entryp,spec); + content_type = (char *)apr_table_get(r->headers_in, "Content-Type"); + if (r->method_number != M_POST + || content_type == NULL + || ! STRCASEEQ('a','A', "application/x-www-form-urlencoded", content_type)) { + break; + } + content_length = (char*)apr_table_get(r->headers_in, HTTP_CONTENT_LENGTH); + DBG(r, "content-Type:[%s]", content_type); + DBG(r, "content-Length:[%s]", content_length); + if (content_length && strlen(content_length) != 0) { + if (STRCASEEQ('A','a', "application/x-www-form-urlencoded", content_type)) { + long cl = (long)chxj_atoi(content_length) * 3; + if (cl > 0) { + apr_table_setn(r->headers_in, "CHXJ_ORIG_CONTENT_LENGTH", content_length); + apr_table_setn(r->headers_in, "Content-Length", apr_psprintf(r->pool, "%ld", cl)); + } + } + } break; @@ -184,6 +204,8 @@ chxj_headers_fixup(request_rec *r) } + + DBG(r, "end chxj_headers_fixup()"); return DECLINED; @@ -1017,6 +1039,7 @@ chxj_input_filter(ap_filter_t *f, char *data_bucket; char *data_brigade; char *content_type; + char *content_length; device_table *spec; char *user_agent; mod_chxj_config *dconf; @@ -1033,13 +1056,16 @@ chxj_input_filter(ap_filter_t *f, ibb = apr_brigade_create(r->pool, c->bucket_alloc); obb = apr_brigade_create(r->pool, c->bucket_alloc); - content_type = (char*)apr_table_get(r->headers_in, "Content-Type"); - if (content_type - && strncasecmp("multipart/form-data", content_type, 19) == 0) { - - DBG(r, "detect multipart/form-data"); + content_type = (char *)apr_table_get(r->headers_in, "Content-Type"); + content_length = (char *)apr_table_get(r->headers_in, "Content-Length"); + if (mode != AP_MODE_READBYTES + || r->method_number != M_POST + || content_type == NULL + || ! STRCASEEQ('a','A', "application/x-www-form-urlencoded", content_type) + || content_length == NULL + || strlen(content_length) == 0 + || strcmp("0", content_length) == 0) { ap_remove_input_filter(f); - return ap_get_brigade(f->next, bb, mode, block, readbytes); } @@ -1095,7 +1121,7 @@ chxj_input_filter(ap_filter_t *f, data_bucket = apr_palloc(r->pool, len+1); memset((void*)data_bucket, 0, len+1); memcpy(data_bucket, data, len); - DBG(r, "(in)POSTDATA:[%s]", data_bucket); + DBG(r, "(in)POSTDATA:[%.*s]LEN:[%d] method_number:[%d]", len, data_bucket, len, r->method_number); data_brigade = apr_pstrcat(r->pool, data_brigade, data_bucket, NULL); } @@ -1123,7 +1149,8 @@ chxj_input_filter(ap_filter_t *f, spec); if (len > 0) { - DBG(r, "(in:convert)POSTDATA:[%s]", data_brigade); + DBG(r, "(in:convert)POSTDATA:[%.*s]:LEN:[%d]", len, data_brigade, len); +#if 0 obb = apr_brigade_create(r->pool, c->bucket_alloc); tmp_heap = apr_bucket_heap_create(data_brigade, len, @@ -1133,6 +1160,33 @@ chxj_input_filter(ap_filter_t *f, APR_BRIGADE_INSERT_TAIL(obb, tmp_heap); APR_BRIGADE_INSERT_TAIL(obb, eos); APR_BRIGADE_CONCAT(bb, obb); +#else + if (STRCASEEQ('P','p', "post", r->method)) { + char *new_area; + if (STRCASEEQ('a','A', "application/x-www-form-urlencoded", content_type)) { + if (content_length && strlen(content_length) != 0) { + apr_size_t cl = (apr_size_t)chxj_atoi(content_length); + new_area = apr_palloc(r->pool, cl + 1); + memset(new_area, 0, cl+1); + if (len < cl) { + apr_size_t pp; + memcpy(new_area, data_brigade, len); + for (pp=0; pppool, c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(bb, b); + eos = apr_bucket_eos_create(f->c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(bb, eos); +#endif + } DBG(r, "end of chxj_input_filter()"); @@ -1890,7 +1944,7 @@ cmd_set_cookie_timeout( dconf = (mod_chxj_config *)mconfig; - dconf->cookie_timeout = atoi(arg); + dconf->cookie_timeout = chxj_atoi(arg); return NULL; }