/*
- * 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_buffered_write.h"
#include "chxj_str_util.h"
+#include "chxj_header_inf.h"
#define GET_XHTML(X) ((xhtml_t*)(X))
#undef W_L
static char *s_xhtml_1_0_end_blink_tag (void *pdoc, Node *node);
static char *s_xhtml_1_0_start_marquee_tag (void *pdoc, Node *node);
static char *s_xhtml_1_0_end_marquee_tag (void *pdoc, Node *node);
+static char *s_xhtml_1_0_newline_mark (void *pdoc, Node *node);
static void s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec);
static int s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt);
s_xhtml_1_0_start_marquee_tag,
s_xhtml_1_0_end_marquee_tag,
},
+ /* tagNLMARK */
+ {
+ s_xhtml_1_0_newline_mark,
+ NULL,
+ },
};
/**
apr_size_t srclen,
apr_size_t *dstlen,
chxjconvrule_entry *entryp,
- cookie_t *UNUSED(cookie)
+ cookie_t *cookie
)
{
char *dst = NULL;
s_init_xhtml(&xhtml, &doc, r, spec);
xhtml.entryp = entryp;
+ xhtml.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. */
doc->r = r;
xhtml->doc = doc;
xhtml->spec = spec;
- xhtml->out = qs_alloc_zero_byte_string(r);
+ xhtml->out = qs_alloc_zero_byte_string(r->pool);
xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
xhtml->doc->parse_mode = PARSE_MODE_CHTML;
}
}
+char *
+chxj_xhtml_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
+{
+ apr_size_t ii;
+ Doc __doc;
+ Doc *doc;
+ xhtml_t __xhtml;
+ xhtml_t *xhtml;
+ char one_byte[2];
+ char two_byte[3];
+ apr_pool_t *pool;
+
+ xhtml = &__xhtml;
+ doc = &__doc;
+
+ DBG(r, "REQ[%X] start chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
+ memset(doc, 0, sizeof(Doc));
+ memset(xhtml, 0, sizeof(xhtml_t));
+
+ doc->r = r;
+ xhtml->doc = doc;
+ xhtml->spec = spec;
+ xhtml->out = qs_alloc_zero_byte_string(r->pool);
+ xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
+ xhtml->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_xhtml_search_emoji(xhtml, (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);
+ }
+ }
+ xhtml->out = chxj_buffered_write_flush(xhtml->out, &doc->buf);
+
+ DBG(r, "REQ[%X] end chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
+ return xhtml->out;
+}
+
+
/**
* It is a handler who processes the HTML tag.
*
}
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</html>");
- W_NLCODE();
return xhtml->out;
}
Attr *attr;
Doc *doc = xhtml->doc;
int content_type_flag = 0;
+ request_rec *r = doc->r;
W_L("<meta");
/*--------------------------------------------------------------------------*/
W_L(" ");
W_V(name);
W_L("=\"");
- W_L("text/html; charset=Windows-31J");
+ W_V(chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
W_L("\"");
}
else {
}
}
W_L(" />");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("<head>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</head>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</title>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(" />");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</body>");
- W_NLCODE();
return xhtml->out;
}
}
else if (STRCASEEQ('h','H',"href", name) && value && *value) {
value = chxj_encoding_parameter(r, value);
+ if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
+ value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
+ }
W_L(" href=\"");
W_V(value);
W_L("\"");
Doc *doc = xhtml->doc;
W_L("</a>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(" />");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("<br />");
- W_NLCODE();
return xhtml->out;
}
}
if (xhtml->font_color_flag) {
W_L("</font>");
- W_NLCODE();
xhtml->font_color_flag--;
}
return xhtml->out;
Doc *doc = xhtml->doc;
request_rec *r = doc->r;
Attr *attr;
+ char *new_hidden_tag = NULL;
+ char *attr_action = NULL;
+ char *attr_method = NULL;
+ char *attr_name = NULL;
- W_L("<form");
/*--------------------------------------------------------------------------*/
/* Get Attributes */
/*--------------------------------------------------------------------------*/
char *name = qs_get_attr_name(doc,attr);
char *value = qs_get_attr_value(doc,attr);
if (STRCASEEQ('a','A',"action",name)) {
- value = chxj_encoding_parameter(r, value);
- W_L(" action=\"");
- W_V(value);
- W_L("\"");
+ attr_action = chxj_encoding_parameter(r, value);
+ attr_action = chxj_add_cookie_parameter(r, attr_action, xhtml->cookie);
}
else if (STRCASEEQ('m','M',"method",name)) {
- W_L(" method=\"");
- W_V(value);
- W_L("\"");
+ attr_method = apr_pstrdup(doc->pool, value);
}
else if (STRCASEEQ('u','U',"utn",name)) {
/* ignore */
}
+ else if (STRCASEEQ('n','N',"name",name)) {
+ attr_name = apr_pstrdup(doc->pool, value);
+ }
+ }
+
+ int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
+
+ W_L("<form");
+ if (attr_action) {
+ char *q;
+ char *old_qs = NULL;
+ q = strchr(attr_action, '?');
+ if (q) {
+ new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &old_qs, CHXJ_FALSE, CHXJ_FALSE, xhtml->entryp);
+ if (new_hidden_tag || old_qs) {
+ *q = 0;
+ }
+ }
+ W_L(" action=\"");
+ W_V(attr_action);
+ if (old_qs) {
+ W_L("?");
+ W_V(old_qs);
+ }
+ W_L("\"");
+ }
+ if (attr_method) {
+ W_L(" method=\"");
+ W_V(attr_method);
+ W_L("\"");
+ }
+ if (attr_name) {
+ W_L(" name=\"");
+ W_V(attr_name);
+ W_L("\"");
}
W_L(">");
- W_NLCODE();
+ if (new_hidden_tag) {
+ W_V(new_hidden_tag);
+ }
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</form>");
- W_NLCODE();
return xhtml->out;
}
/*--------------------------------------------------------------------------*/
/* Get Attributes */
/*--------------------------------------------------------------------------*/
- type = qs_get_type_attr(doc, node, r);
- name = qs_get_name_attr(doc, node, r);
- 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);
- checked = qs_get_checked_attr(doc,node,doc->buf.pool);
- accesskey = qs_get_accesskey_attr(doc, node, r);
- size = qs_get_size_attr(doc, node, r);
+ 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,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 (type) {
type = qs_trim_string(doc->buf.pool, type);
}
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=\"checked\"");
}
W_L(" />");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("<center>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</center>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(" />");
- W_NLCODE();
return xhtml->out;
}
xhtml->pre_flag++;
W_L("<pre>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</pre>");
- W_NLCODE();
xhtml->pre_flag--;
return xhtml->out;
W_L("\"");
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</p>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</ul>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</h1>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</h2>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</h3>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</h4>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</h5>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</h6>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</ol>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</li>");
- W_NLCODE();
return xhtml->out;
}
if (STRCASEEQ('s','S',"src",name)) {
value = chxj_encoding_parameter(r, value);
+ value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
+ value = chxj_add_cookie_no_update_parameter(r, value);
#ifdef IMG_NOT_CONVERT_FILENAME
W_L(" src=\"");
}
}
W_L(" />");
- W_NLCODE();
return xhtml->out;
}
W_L(" multiple=\"true\"");
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</select>");
- W_NLCODE();
return xhtml->out;
}
value = apr_pstrdup(doc->buf.pool, val);
}
}
- if (value && *value) {
+ if (value) {
W_L(" value=\"");
W_V(value);
W_L("\"");
Doc *doc = xhtml->doc;
W_L("</option>");
- W_NLCODE();
return xhtml->out;
}
W_L("\"");
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</div>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</div>");
- W_NLCODE();
return xhtml->out;
}
Doc *doc = xhtml->doc;
W_L("</textarea>");
- W_NLCODE();
xhtml->textarea_flag--;
return xhtml->out;
tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
memset(tmp, 0, qs_get_node_size(doc,child)+1);
- tdst = qs_alloc_zero_byte_string(r);
+ tdst = qs_alloc_zero_byte_string(doc->buf.pool);
memset(one_byte, 0, sizeof(one_byte));
tdst_len = 0;
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("<blockquote>");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</blockquote>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</dir>");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("<dl>");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</dl>");
- W_NLCODE();
return xhtml->out;
}
}
}
W_L(">");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</menu>");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</blink>");
- W_NLCODE();
return xhtml->out;
}
xhtml_t *xhtml = GET_XHTML(pdoc);
Doc *doc = xhtml->doc;
W_L("</marquee>");
+ return xhtml->out;
+}
+
+
+/**
+ * It is handler who processes the New Line Code.
+ */
+static char *
+s_xhtml_1_0_newline_mark(void *pdoc, Node *UNUSED(node))
+{
+ xhtml_t *xhtml = GET_XHTML(pdoc);
+ Doc *doc = xhtml->doc;
W_NLCODE();
return xhtml->out;
}