/*
- * 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
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. */
}
+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.
*
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 {
}
else if (STRCASEEQ('h','H',"href", name) && value && *value) {
value = chxj_encoding_parameter(r, value);
- value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
+ 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("\"");
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);
- value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
- char *q;
- q = strchr(value, '?');
- if (q) {
- new_hidden_tag = chxj_form_action_to_hidden_tag(doc->pool, value, 1);
- *q = 0;
- }
- 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)) {
- W_L(" name=\"");
- W_V(value);
- W_L("\"");
+ 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(">");
if (new_hidden_tag) {
W_V(new_hidden_tag);
if (STRCASEEQ('s','S',"src",name)) {
value = chxj_encoding_parameter(r, value);
value = chxj_add_cookie_parameter(r, value, xhtml->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);
#ifdef IMG_NOT_CONVERT_FILENAME
W_L(" src=\"");
value = apr_pstrdup(doc->buf.pool, val);
}
}
- if (value && *value) {
+ if (value) {
W_L(" value=\"");
W_V(value);
W_L("\"");