/*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2011 Atsushi Konno All rights reserved.
* Copyright (C) 2005 QSDN,Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "chxj_img_conv.h"
#include "chxj_qr_code.h"
#include "chxj_encoding.h"
+#include "chxj_header_inf.h"
+#include "chxj_conv_z2h.h"
#define GET_CHTML30(X) ((chtml30_t *)(X))
#undef W_L
s_chtml30_chxjif_tag,
NULL,
},
+ /* tagCHXJRAW */
+ {
+ s_chtml30_chxjif_tag,
+ NULL,
+ },
/* tagNOBR */
{
NULL,
chtml30_t chtml30;
Doc doc;
- DBG(r, "start chxj_convert_chtml30()");
+ DBG(r, "REQ[%X] start %s()",TO_ADDR(r),__func__);
/*--------------------------------------------------------------------------*/
/* If qrcode xml */
*dstlen = srclen;
dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
if (dst) {
- DBG(r,"i found qrcode xml");
- DBG(r, "end chxj_convert_chtml30()");
+ DBG(r,"REQ[%X] found qrcode xml", TO_ADDR(r));
+ DBG(r, "REQ[%X] end %s()",TO_ADDR(r),__func__);
return dst;
}
- DBG(r,"not found qrcode xml");
+ DBG(r,"REQ[%X] not found qrcode xml", TO_ADDR(r));
/*--------------------------------------------------------------------------*/
/* The CHTML structure is initialized. */
chtml30.entryp = entryp;
chtml30.cookie = cookie;
- chxj_set_content_type(r, "text/html; charset=Windows-31J");
+ chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
/*--------------------------------------------------------------------------*/
/* The character string of the input is analyzed. */
chxj_dump_out("[src] CHTML -> CHTML3.0", dst, *dstlen);
#endif
- DBG(r, "end chxj_convert_chtml30()");
+ DBG(r, "REQ[%X] end %s()",TO_ADDR(r),__func__);
return dst;
}
r = chtml30->doc->r;
if (!spec) {
- DBG(r,"spec is NULL");
+ DBG(r,"REQ[%X] spec is NULL", TO_ADDR(r));
}
for (ee = chtml30->conf->emoji;
ee;
ee = ee->next) {
if (ee->imode == NULL) {
- DBG(r, "emoji->imode is NULL");
+ DBG(r, "REQ[%X] emoji->imode is NULL", TO_ADDR(r));
continue;
}
}
+char *
+chxj_chtml30_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
+{
+ apr_size_t ii;
+ Doc __doc;
+ Doc *doc;
+ chtml30_t __chtml30;
+ chtml30_t *chtml30;
+ char one_byte[2];
+ char two_byte[3];
+ apr_pool_t *pool;
+
+ chtml30 = &__chtml30;
+ doc = &__doc;
+
+ DBG(r, "REQ[%X] start %s()", TO_ADDR(r),__func__);
+ memset(doc, 0, sizeof(Doc));
+ memset(chtml30, 0, sizeof(chtml30_t));
+
+ doc->r = r;
+ chtml30->doc = doc;
+ chtml30->spec = spec;
+ chtml30->out = qs_alloc_zero_byte_string(r->pool);
+ chtml30->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
+ chtml30->doc->parse_mode = PARSE_MODE_CHTML;
+
+ apr_pool_create(&pool, r->pool);
+
+ chxj_buffered_write_init(pool, &doc->buf);
+
+ for (ii=0; ii<len; ii++) {
+ char *out;
+ int rtn;
+
+ rtn = s_chtml30_search_emoji(chtml30, (char *)&src[ii], &out);
+ if (rtn) {
+ W_V(out);
+ ii+=(rtn - 1);
+ continue;
+ }
+
+ if (is_sjis_kanji(src[ii])) {
+ two_byte[0] = src[ii+0];
+ two_byte[1] = src[ii+1];
+ two_byte[2] = 0;
+ W_V(two_byte);
+ ii++;
+ }
+ else {
+ one_byte[0] = src[ii+0];
+ one_byte[1] = 0;
+ W_V(one_byte);
+ }
+ }
+ chtml30->out = chxj_buffered_write_flush(chtml30->out, &doc->buf);
+
+ DBG(r, "REQ[%X] end %s()", TO_ADDR(r),__func__);
+ return chtml30->out;
+}
+
+
/**
* It is a handler who processes the HTML tag.
*
if (content_type_flag) {
W_L(" ");
W_V(name);
- W_L("=\"text/html; charset=Windows-31J\"");
+ W_L("=\"");
+ W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
+ W_L("\"");
}
else
if (refresh_flag) {
/* CHTML1.0 */
/*----------------------------------------------------------------------*/
value = chxj_encoding_parameter(r, value);
- if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "telto:")) {
+ if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
}
W_L(" href=\"");
W_L("<form");
if (attr_action) {
char *q;
+ char *new_query_string = NULL;
q = strchr(attr_action, '?');
if (q) {
- new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag);
- if (new_hidden_tag) {
+ new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE, CHXJ_FALSE, chtml30->entryp);
+ if (new_hidden_tag || new_query_string) {
*q = 0;
}
}
W_L(" action=\"");
W_V(attr_action);
+ if (new_query_string) {
+ W_L("?");
+ W_V(new_query_string);
+ }
W_L("\"");
}
if (attr_method) {
W_L("\"");
}
if (value && *value) {
+ if (type && (STRCASEEQ('s','S',"submit",type) || STRCASEEQ('r','R',"reset",type))) {
+ apr_size_t value_len = strlen(value);
+ value = chxj_conv_z2h(r, value, &value_len, chtml30->entryp);
+ }
+
W_L(" value=\"");
W_V(chxj_add_slash_to_doublequote(doc->pool, value));
W_L("\"");
#ifdef IMG_NOT_CONVERT_FILENAME
value = chxj_encoding_parameter(r, value);
value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
- if (value) {
- value = apr_psprintf(r->pool,
- "%s%c%s=true",
- value,
- (strchr(value, '?')) ? '&' : '?',
- CHXJ_COOKIE_NOUPDATE_PARAM);
- W_L(" src=\"");
- W_V(value);
- W_L("\"");
- }
-
+ value = chxj_add_cookie_no_update_parameter(r, value);
+ W_L(" src=\"");
+ W_V(value);
+ W_L("\"");
#else
value = chxj_img_conv(r,spec,value);
value = chxj_encoding_parameter(r, value);
value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
- if (value) {
- value = apr_psprintf(r->pool,
- "%s%c%s=true",
- value,
- (strchr(value, '?')) ? '&' : '?',
- CHXJ_COOKIE_NOUPDATE_PARAM);
- }
+ value = chxj_add_cookie_no_update_parameter(r, value);
W_L(" src=\"");
W_V(value);
W_L("\"");
value = apr_pstrdup(doc->buf.pool, val);
}
}
- if (value && *value) {
+ if (value) {
W_L(" value=\"");
W_V(value);
W_L("\"");
char one_byte[2];
int ii;
int tdst_len;
+ apr_size_t z2h_input_len;
chtml30 = GET_CHTML30(pdoc);
doc = chtml30->doc;
tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
}
}
+ z2h_input_len = strlen(tdst);
+ tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, chtml30->entryp);
+
W_V(tdst);
return chtml30->out;
}