/*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2009 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_qr_code.h"
#include "chxj_encoding.h"
#include "chxj_buffered_write.h"
+#include "chxj_header_inf.h"
#define GET_CHTML20(X) ((chtml20_t*)(X))
static char *s_chtml20_end_blink_tag (void *pdoc, Node *node);
static char *s_chtml20_start_marquee_tag (void *pdoc, Node *node);
static char *s_chtml20_end_marquee_tag (void *pdoc, Node *node);
+static char *s_chtml20_newline_mark (void *pdoc, Node *node);
static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
s_chtml20_start_marquee_tag,
s_chtml20_end_marquee_tag,
},
+ /* tagNLMARK */
+ {
+ s_chtml20_newline_mark,
+ NULL,
+ },
};
/**
chtml20.entryp = entryp;
chtml20.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. */
return 0;
}
+char *
+chxj_chtml20_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
+{
+ apr_size_t ii;
+ Doc __doc;
+ Doc *doc;
+ chtml20_t __chtml20;
+ chtml20_t *chtml20;
+ char one_byte[2];
+ char two_byte[3];
+ apr_pool_t *pool;
+
+ chtml20 = &__chtml20;
+ doc = &__doc;
+
+ DBG(r, "REQ[%X] start chxj_chtml20_emoji_eonly_converter()", (apr_size_t)(unsigned int)r);
+ memset(doc, 0, sizeof(Doc));
+ memset(chtml20, 0, sizeof(chtml20_t));
+
+ doc->r = r;
+ chtml20->doc = doc;
+ chtml20->spec = spec;
+ chtml20->out = qs_alloc_zero_byte_string(r->pool);
+ chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
+ chtml20->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_chtml20_search_emoji(chtml20, (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);
+ }
+ }
+ chtml20->out = chxj_buffered_write_flush(chtml20->out, &doc->buf);
+
+ DBG(r, "REQ[%X] end chxj_chtml20_emoji_eonly_converter()", (apr_size_t)(unsigned int)r);
+ return chtml20->out;
+}
+
/**
* It is a handler who processes the HTML tag.
/* start HTML tag */
/*--------------------------------------------------------------------------*/
W_L("<html>");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</html>");
- W_NLCODE();
return chtml20->out;
}
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) {
char *buf = apr_pstrdup(r->pool, value);
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
doc = chtml20->doc;
W_L("<head>");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</head>");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("<title>");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</title>");
- W_NLCODE();
return chtml20->out;
}
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</body>");
- W_NLCODE();
return chtml20->out;
}
/* CHTML1.0 */
/*--------------------------------------------------------------------*/
value = chxj_encoding_parameter(r, value);
- value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
+ if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
+ value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
+ }
W_L(" href=\"");
W_V(value);
W_L("\"");
r = doc->r;
W_L("</a>");
- W_NLCODE();
return chtml20->out;
}
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("<br>");
- W_NLCODE();
return chtml20->out;
}
static char *
s_chtml20_start_form_tag(void *pdoc, Node *node)
{
- chtml20_t *chtml20;
- Doc *doc;
+ chtml20_t *chtml20;
+ Doc *doc;
request_rec *r;
- Attr *attr;
+ Attr *attr;
+ char *new_hidden_tag = NULL;
+ char *attr_method = NULL;
+ char *attr_action = NULL;
chtml20 = GET_CHTML20(pdoc);
doc = chtml20->doc;
r = doc->r;
- W_L("<form");
/*--------------------------------------------------------------------------*/
/* Get Attributes */
/*--------------------------------------------------------------------------*/
for (attr = qs_get_attr(doc,node);
attr;
attr = qs_get_next_attr(doc,attr)) {
- char *name = qs_get_attr_name(doc,attr);
- char *value = qs_get_attr_value(doc,attr);
+ char *name;
+ char *value;
+ name = qs_get_attr_name(doc,attr);
+ value = qs_get_attr_value(doc,attr);
+
switch(*name) {
case 'a':
case 'A':
/*--------------------------------------------------------------------*/
/* CHTML 1.0 */
/*--------------------------------------------------------------------*/
- value = chxj_encoding_parameter(r, value);
- value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
-
- W_L(" action=\"");
- W_V(value);
- W_L("\"");
+ attr_action = chxj_encoding_parameter(r, value);
+ attr_action= chxj_add_cookie_parameter(r, attr_action, chtml20->cookie);
}
break;
/*--------------------------------------------------------------------*/
/* CHTML 1.0 */
/*--------------------------------------------------------------------*/
- W_L(" method=\"");
- W_V(value);
- W_L("\"");
+ attr_method = apr_pstrdup(doc->pool, value);
}
break;
break;
}
}
- W_L(">");
- W_NLCODE();
+ int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
+
+ 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, &new_query_string, CHXJ_TRUE, CHXJ_FALSE, chtml20->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(" method=\"");
+ W_V(attr_method);
+ W_L("\"");
+ }
+ W_L(">");
+ if (new_hidden_tag) {
+ W_V(new_hidden_tag);
+ }
return chtml20->out;
}
r = doc->r;
W_L("</form>");
- W_NLCODE();
return chtml20->out;
}
type = qs_get_type_attr(doc, node, doc->buf.pool);
name = qs_get_name_attr(doc, node, doc->buf.pool);
value = qs_get_value_attr(doc,node,doc->buf.pool);
- istyle = qs_get_istyle_attr(doc,node,r);
- max_length = qs_get_maxlength_attr(doc,node,r);
+ istyle = qs_get_istyle_attr(doc,node,doc->buf.pool);
+ max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
checked = qs_get_checked_attr(doc,node,doc->buf.pool);
accesskey = qs_get_accesskey_attr(doc, node, doc->buf.pool);
size = qs_get_size_attr(doc, node, doc->buf.pool);
}
if (value && *value) {
W_L(" value=\"");
- W_V(value);
+ W_V(chxj_add_slash_to_doublequote(doc->pool, value));
W_L("\"");
}
if (accesskey && *accesskey) {
W_L(" checked");
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</center>");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("<ul>");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</ul>");
- W_NLCODE();
return chtml20->out;
}
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</ol>");
- W_NLCODE();
return chtml20->out;
}
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
#ifdef IMG_NOT_CONVERT_FILENAME
value = chxj_encoding_parameter(r, value);
value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
- if (value) {
- value = apr_psprintf(doc->buf.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 = chxj_img_conv(r, spec, value);
value = chxj_encoding_parameter(r, value);
value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
- if (value) {
- value = apr_psprintf(doc->buf.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("\"");
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
W_L(" multiple");
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
doc = chtml20->doc;
W_L("</select>");
- W_NLCODE();
return chtml20->out;
}
}
}
- if (value && *value) {
+ if (value) {
W_L(" value=\"");
W_V(value);
W_L("\"");
Doc *doc = chtml20->doc;
W_L("</div>");
- W_NLCODE();
return chtml20->out;
}
doc = chtml20->doc;
W_L("</h1>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</h2>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</h3>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</h4>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</h5>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</h6>");
- W_NLCODE();
return chtml20->out;
}
chtml20->pre_flag++;
W_L("<pre>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</pre>");
- W_NLCODE();
chtml20->pre_flag--;
return chtml20->out;
W_L("\"");
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
r = doc->r;
W_L("</p>");
- W_NLCODE();
return chtml20->out;
}
}
}
W_L(">");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</textarea>");
- W_NLCODE();
chtml20->textarea_flag--;
return chtml20->out;
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("<blockquote>");
- W_NLCODE();
return chtml20->out;
}
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("</blockquote>");
- W_NLCODE();
return chtml20->out;
}
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("<dir>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</dir>");
- W_NLCODE();
return chtml20->out;
}
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("<dl>");
- W_NLCODE();
return chtml20->out;
}
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("</dl>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("<menu>");
- W_NLCODE();
return chtml20->out;
}
Doc *doc = chtml20->doc;
W_L("</menu>");
- W_NLCODE();
return chtml20->out;
}
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("</blink>");
- W_NLCODE();
return chtml20->out;
}
chtml20_t *chtml20 = GET_CHTML20(pdoc);
Doc *doc = chtml20->doc;
W_L("</marquee>");
+ return chtml20->out;
+}
+
+
+/**
+ * * It is handler who processes the New Line Code.
+ * */
+static char *
+s_chtml20_newline_mark(void *pdoc, Node *UNUSED(node))
+{
+ chtml20_t *chtml20 = GET_CHTML20(pdoc);
+ Doc *doc = chtml20->doc;
W_NLCODE();
return chtml20->out;
}