OSDN Git Service

* Bug with wrong treatment of QUERY_STRING when POST is done to another site.
[modchxj/mod_chxj.git] / src / chxj_chtml10.c
index 0a81f15..5482b65 100644 (file)
@@ -21,6 +21,7 @@
 #include "chxj_qr_code.h"
 #include "chxj_cookie.h"
 #include "chxj_encoding.h"
+#include "chxj_str_util.h"
 #include "chxj_buffered_write.h"
 
 #define GET_CHTML10(X) ((chtml10_t*)(X))
 #define W10_V(X)          do { chtml10->out = (X) ? BUFFERED_WRITE_VALUE(chtml10->out, &doc->buf, (X))  \
                                                   : BUFFERED_WRITE_LITERAL(chtml10->out, &doc->buf, ""); } while(0)
 
-static char* s_chtml10_start_html_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_html_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_meta_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_meta_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_textarea_tag (void* pdoc, Node* node);
-static char* s_chtml10_end_textarea_tag   (void* pdoc, Node* node);
-static char* s_chtml10_start_p_tag        (void* pdoc, Node* node);
-static char* s_chtml10_end_p_tag          (void* pdoc, Node* node);
-static char* s_chtml10_start_pre_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_pre_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_ul_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_ul_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_li_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_li_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_ol_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_ol_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h1_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h1_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h2_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h2_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h3_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h3_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h4_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h4_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h5_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h5_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h6_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h6_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_head_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_head_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_title_tag    (void* pdoc, Node* node);
-static char* s_chtml10_end_title_tag      (void* pdoc, Node* node);
-static char* s_chtml10_start_base_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_base_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_body_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_body_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_a_tag        (void* pdoc, Node* node);
-static char* s_chtml10_end_a_tag          (void* pdoc, Node* node);
-static char* s_chtml10_start_br_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_br_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_tr_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_tr_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_font_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_font_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_input_tag    (void* pdoc, Node* node);
-static char* s_chtml10_end_input_tag      (void* pdoc, Node* node);
-static char* s_chtml10_start_form_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_form_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_center_tag   (void* pdoc, Node* node);
-static char* s_chtml10_end_center_tag     (void* pdoc, Node* node);
-static char* s_chtml10_start_hr_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_hr_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_img_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_img_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_select_tag   (void* pdoc, Node* node);
-static char* s_chtml10_end_select_tag     (void* pdoc, Node* node);
-static char* s_chtml10_start_option_tag   (void* pdoc, Node* node);
-static char* s_chtml10_end_option_tag     (void* pdoc, Node* node);
-static char* s_chtml10_start_div_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_div_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_blockquote_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_blockquote_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_dir_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_dir_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_dl_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_dl_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_dt_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_dt_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_dd_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_dd_tag         (void* pdoc, Node* node);
-
-static void  s_init_chtml10(chtml10_t* chtml, Doc* doc, request_rec* r, device_table* spec);
-
-static int   s_chtml10_search_emoji(chtml10_t* chtml, char* txt, char** rslt);
-static char* s_chtml10_chxjif_tag        (void* pdoc, Node* node);
-static char* s_chtml10_text              (void* pdoc, Node* node);
+static char *s_chtml10_start_html_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_html_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_meta_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_meta_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_textarea_tag (void *pdoc, Node *node);
+static char *s_chtml10_end_textarea_tag   (void *pdoc, Node *node);
+static char *s_chtml10_start_p_tag        (void *pdoc, Node *node);
+static char *s_chtml10_end_p_tag          (void *pdoc, Node *node);
+static char *s_chtml10_start_pre_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_pre_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_ul_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_ul_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_li_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_li_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_ol_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_ol_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h1_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h1_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h2_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h2_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h3_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h3_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h4_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h4_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h5_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h5_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h6_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h6_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_head_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_head_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_title_tag    (void *pdoc, Node *node);
+static char *s_chtml10_end_title_tag      (void *pdoc, Node *node);
+static char *s_chtml10_start_base_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_base_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_body_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_body_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_a_tag        (void *pdoc, Node *node);
+static char *s_chtml10_end_a_tag          (void *pdoc, Node *node);
+static char *s_chtml10_start_br_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_br_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_tr_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_tr_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_font_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_font_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_input_tag    (void *pdoc, Node *node);
+static char *s_chtml10_end_input_tag      (void *pdoc, Node *node);
+static char *s_chtml10_start_form_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_form_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_center_tag   (void *pdoc, Node *node);
+static char *s_chtml10_end_center_tag     (void *pdoc, Node *node);
+static char *s_chtml10_start_hr_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_hr_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_img_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_img_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_select_tag   (void *pdoc, Node *node);
+static char *s_chtml10_end_select_tag     (void *pdoc, Node *node);
+static char *s_chtml10_start_option_tag   (void *pdoc, Node *node);
+static char *s_chtml10_end_option_tag     (void *pdoc, Node *node);
+static char *s_chtml10_start_div_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_div_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_blockquote_tag(void *pdoc, Node *node);
+static char *s_chtml10_end_blockquote_tag (void *pdoc, Node *node);
+static char *s_chtml10_start_dir_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_dir_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_dl_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_dl_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_dt_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_dt_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_dd_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_dd_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_menu_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_menu_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_plaintext_tag(void *pdoc, Node *node);
+static char *s_chtml10_start_plaintext_tag_inner(void  *pdoc, Node *node);
+static char *s_chtml10_end_plaintext_tag  (void *pdoc, Node *node);
+
+static void  s_init_chtml10(chtml10_t *chtml, Doc *doc, request_rec *r, device_table *spec);
+
+static int   s_chtml10_search_emoji(chtml10_t *chtml, char *txt, char **rslt);
+static char *s_chtml10_chxjif_tag        (void *pdoc, Node *node);
+static char *s_chtml10_text              (void *pdoc, Node *node);
 
 tag_handler chtml10_handler[] = {
   /* tagHTML */
@@ -351,6 +357,26 @@ tag_handler chtml10_handler[] = {
     s_chtml10_start_dd_tag,
     s_chtml10_end_dd_tag,
   },
+  /* tagMENU */
+  {
+    s_chtml10_start_menu_tag,
+    s_chtml10_end_menu_tag,
+  },
+  /* tagPLAINTEXT */
+  {
+    s_chtml10_start_plaintext_tag,
+    s_chtml10_end_plaintext_tag,
+  },
+  /* tagBLINK */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagMARQUEE */
+  {
+    NULL,
+    NULL,
+  },
 };
 
 
@@ -363,19 +389,19 @@ tag_handler chtml10_handler[] = {
  * @param src   [i]   The character string before the converting is appointed.
  * @return The character string after the converting is returned.
  */
-char*
+char *
 chxj_exchange_chtml10(
-  request_rec*        r,
-  device_table*       spec,
-  const char*         src,
+  request_rec         *r,
+  device_table        *spec,
+  const char          *src,
   apr_size_t          srclen,
-  apr_size_t*         dstlen,
-  chxjconvrule_entryentryp,
+  apr_size_t          *dstlen,
+  chxjconvrule_entry  *entryp,
   cookie_t*           cookie
 )
 {
-  char*     dst;
-  char*     ss;
+  char      *dst;
+  char      *ss;
   chtml10_t chtml10;
   Doc       doc;
   apr_time_t t;
@@ -445,7 +471,7 @@ chxj_exchange_chtml10(
   chxj_dump_out("[dst] CHTML -> CHTML1.0", dst, *dstlen);
 #endif
 
-  DBG(r, "end   chxj_exchange_chtml10() cookie_id=[%s] time=[%lld]", (cookie) ? cookie->cookie_id : "", apr_time_now() - t);
+  DBG(r, "end   chxj_exchange_chtml10() cookie_id=[%s] time=[%" APR_INT64_T_FMT  "]", (cookie) ? cookie->cookie_id : "", apr_time_now() - t);
 
   return dst;
 }
@@ -463,10 +489,10 @@ chxj_exchange_chtml10(
  */
 static void
 s_init_chtml10(
-  chtml10_t*    chtml10, 
-  Doc*          doc, 
-  request_rec*  r, 
-  device_tablespec)
+  chtml10_t     *chtml10, 
+  Doc           *doc, 
+  request_rec   *r, 
+  device_table  *spec)
 {
   memset(doc,     0, sizeof(Doc));
   memset(chtml10, 0, sizeof(chtml10_t));
@@ -492,11 +518,11 @@ s_init_chtml10(
  * @return When corresponding EMOJI exists, it returns it excluding 0. 
  */
 static int
-s_chtml10_search_emoji(chtml10_t* chtml10, char* txt, char** rslt)
+s_chtml10_search_emoji(chtml10_t *chtml10, char *txt, char **rslt)
 {
-  emoji_t*      ee;
-  request_rec*  r;
-  device_tablespec;
+  emoji_t       *ee;
+  request_rec   *r;
+  device_table  *spec;
   int           len;
 
   spec = chtml10->spec;
@@ -545,12 +571,12 @@ s_chtml10_search_emoji(chtml10_t* chtml10, char* txt, char** rslt)
  * @param node   [i]   The HTML tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_html_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_html_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -573,12 +599,12 @@ s_chtml10_start_html_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The HTML tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_html_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_html_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   
   chtml10 = GET_CHTML10(pdoc);
@@ -599,12 +625,10 @@ s_chtml10_end_html_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The META tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_meta_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_meta_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml10_t* chtml10;
-
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   /* ignore */
 
@@ -620,12 +644,10 @@ s_chtml10_start_meta_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The META tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_meta_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t* chtml10;
-
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -639,12 +661,12 @@ s_chtml10_end_meta_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The HEAD tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_head_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_head_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -664,12 +686,12 @@ s_chtml10_start_head_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The HEAD tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_head_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_head_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -689,18 +711,18 @@ s_chtml10_end_head_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The OL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_ol_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_ol_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("<ol>\r\n");
+  W10_L("<ol>");
 
   return chtml10->out;
 }
@@ -714,18 +736,18 @@ s_chtml10_start_ol_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The OL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_ol_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("</ol>\r\n");
+  W10_L("</ol>");
 
   return chtml10->out;
 }
@@ -739,18 +761,18 @@ s_chtml10_end_ol_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The UL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_ul_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10    = GET_CHTML10(pdoc);
   doc        = chtml10->doc;
   r          = doc->r;
 
-  W10_L("<ul>\r\n");
+  W10_L("<ul>");
 
   return chtml10->out;
 }
@@ -764,18 +786,18 @@ s_chtml10_start_ul_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The UL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_ul_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("</ul>\r\n");
+  W10_L("</ul>");
 
   return chtml10->out;
 }
@@ -789,12 +811,12 @@ s_chtml10_end_ul_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The LI tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_li_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_li_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -814,11 +836,10 @@ s_chtml10_start_li_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The LI tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_li_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_li_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t  *chtml10 = GET_CHTML10(pdoc);
   return chtml10->out;
 }
 
@@ -831,13 +852,13 @@ s_chtml10_end_li_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H1 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h1_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_h1_tag(void *pdoc, Node *node) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  Attr*         attr;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -847,10 +868,8 @@ s_chtml10_start_h1_tag(void* pdoc, Node* node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name;
-    char* value;
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('a','A',"align", name)) {
       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
         W10_L(" align=\"");
@@ -874,12 +893,12 @@ s_chtml10_start_h1_tag(void* pdoc, Node* node)
  * @param node   [i]   The H1 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h1_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -899,7 +918,7 @@ s_chtml10_end_h1_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H2 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
+static char *
 s_chtml10_start_h2_tag(void *pdoc, Node *node) 
 {
   Doc           *doc;
@@ -942,12 +961,12 @@ s_chtml10_start_h2_tag(void *pdoc, Node *node)
  * @param node   [i]   The H2 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h2_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -983,10 +1002,8 @@ s_chtml10_start_h3_tag(void *pdoc, Node *node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name;
-    char* value;
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('a','A',"align", name)) {
       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
         W10_L(" align=\"");
@@ -1010,12 +1027,12 @@ s_chtml10_start_h3_tag(void *pdoc, Node *node)
  * @param node   [i]   The H3 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h3_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1078,12 +1095,12 @@ s_chtml10_start_h4_tag(void *pdoc, Node *node)
  * @param node   [i]   The H4 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h4_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10  = GET_CHTML10(pdoc);
   doc      = chtml10->doc;
@@ -1106,7 +1123,7 @@ s_chtml10_end_h4_tag(void* pdoc, Node* UNUSED(child))
 static char *
 s_chtml10_start_h5_tag(void *pdoc, Node *node) 
 {
-  Doc           *doc;
+  Doc          *doc;
   request_rec  *r;
   chtml10_t    *chtml10;
   Attr         *attr;
@@ -1119,10 +1136,8 @@ s_chtml10_start_h5_tag(void *pdoc, Node *node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name;
-    char* value;
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('a','A',"align", name)) {
       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
         W10_L(" align=\"");
@@ -1146,12 +1161,12 @@ s_chtml10_start_h5_tag(void *pdoc, Node *node)
  * @param node   [i]   The H5 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h5_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1187,10 +1202,8 @@ s_chtml10_start_h6_tag(void *pdoc, Node *node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name;
-    char* value;
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('a','A',"align", name)) {
       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
         W10_L(" align=\"");
@@ -1217,9 +1230,9 @@ s_chtml10_start_h6_tag(void *pdoc, Node *node)
 static char *
 s_chtml10_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1239,12 +1252,12 @@ s_chtml10_end_h6_tag(void *pdoc, Node *UNUSED(child))
  * @param node   [i]   The TITLE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_title_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_title_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*         doc;
-  request_recr;
-  chtml10_t*   chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  chtml10_t    *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1264,12 +1277,12 @@ s_chtml10_start_title_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The TITLE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_title_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_title_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1289,13 +1302,13 @@ s_chtml10_end_title_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The BASE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_base_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_base_tag(void *pdoc, Node *node) 
 {
-  Attr*         attr;
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  Attr          *attr;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1309,12 +1322,8 @@ s_chtml10_start_base_tag(void* pdoc, Node* node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name;
-    char* value;
-
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('h','H',"href", name)) {
       W10_L(" href=\"");
       W10_V(value);
@@ -1336,10 +1345,10 @@ s_chtml10_start_base_tag(void* pdoc, Node* node)
  * @param node   [i]   The BASE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_base_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_base_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -1353,13 +1362,13 @@ s_chtml10_end_base_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The BODY tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_body_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_body_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1375,10 +1384,7 @@ s_chtml10_start_body_tag(void* pdoc, Node* node)
        attr;
        attr = qs_get_next_attr(doc,attr)) {
 
-    char* name;
-
-    name  = qs_get_attr_name(doc,attr);
-
+    char *name  = qs_get_attr_name(doc,attr);
     switch(*name) {
     case 'a':
     case 'A':
@@ -1449,12 +1455,12 @@ s_chtml10_start_body_tag(void* pdoc, Node* node)
  * @param node   [i]   The BODY tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_body_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_body_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1494,13 +1500,8 @@ s_chtml10_start_a_tag(void *pdoc, Node *node)
   for (attr = qs_get_attr(doc,node);
        attr; 
        attr = qs_get_next_attr(doc,attr)) {
-
-    char *name;
-    char *value;
-
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 'n':
     case 'N':
@@ -1690,12 +1691,8 @@ s_chtml10_start_br_tag(void *pdoc, Node *node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char *name;
-    char *value;
-
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('c','C',"clear",name)) {
       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
         W10_L(" clear=\"");
@@ -1821,12 +1818,14 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
   Doc          *doc;
   request_rec  *r;
   Attr         *attr;
+  char         *new_hidden_tag = NULL;
+  char         *attr_value = NULL;
+  char         *attr_method = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("<form");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1834,12 +1833,8 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char *name;
-    char *value;
-
-    name  = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 'a':
     case 'A':
@@ -1847,12 +1842,8 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        value = chxj_encoding_parameter(r, value);
-        value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
-  
-        W10_L(" action=\"");
-        W10_V(value);
-        W10_L("\"");
+        attr_value = chxj_encoding_parameter(r, value);
+        attr_value = chxj_add_cookie_parameter(r, attr_value, chtml10->cookie);
       }
       break;
 
@@ -1862,9 +1853,7 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W10_L(" method=\"");
-        W10_V(value);
-        W10_L("\"");
+        attr_method = apr_pstrdup(doc->pool, value);
       }
       break;
 
@@ -1883,7 +1872,31 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
     }
   }
 
+  int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
+
+  W10_L("<form");
+  if (attr_value) {
+    char *q;
+    q = strchr(attr_value, '?');
+    if (q) {
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_value, 0, post_flag);
+      if (new_hidden_tag) {
+        *q = 0;
+      }
+    }
+    W10_L(" action=\"");
+    W10_V(attr_value);
+    W10_L("\"");
+  }
+  if (attr_method) {
+    W10_L(" method=\"");
+    W10_V(attr_method);
+    W10_L("\"");
+  }
   W10_L(">");
+  if (new_hidden_tag) {
+    W10_V(new_hidden_tag);
+  }
 
   return chtml10->out;
 }
@@ -1897,12 +1910,12 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
  * @param node   [i]   The FORM tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_form_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_form_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -1922,20 +1935,20 @@ s_chtml10_end_form_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The INPUT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_input_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_input_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
-  char*         max_length;
-  char*         type;
-  char*         name;
-  char*         value;
-  char*         istyle;
-  char*         size;
-  char*         checked;
-  char*         accesskey;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  char          *max_length;
+  char          *type;
+  char          *name;
+  char          *value;
+  char          *istyle;
+  char          *size;
+  char          *checked;
+  char          *accesskey;
 
   chtml10     = GET_CHTML10(pdoc);
   doc         = chtml10->doc;
@@ -1980,28 +1993,28 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
     }
   }
 
-  if (size) {
+  if (size && *size != 0) {
     W10_L(" size=\"");
     W10_V(size);
     W10_L("\"");
   }
 
-  if (name) {
+  if (name && *name != 0) {
     W10_L(" name=\"");
     W10_V(name);
     W10_L("\"");
   }
 
-  if (value) {
+  if (value && *value != 0) {
     W10_L(" value=\"");
-    W10_V(value);
-    W10_L("\" ");
+    W10_V(chxj_add_slash_to_doublequote(doc->pool,value));
+    W10_L("\"");
   }
 
-  if (accesskey) {
+  if (accesskey && *accesskey != 0) {
     W10_L(" accesskey=\"");
     W10_V(accesskey);
-    W10_L("\" ");
+    W10_L("\"");
   }
 
   if (istyle) {
@@ -2013,14 +2026,14 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
   /*--------------------------------------------------------------------------*/
   /* The figure is default for the password.                                  */
   /*--------------------------------------------------------------------------*/
-  if (max_length) {
+  if (max_length && *max_length != 0) {
     W10_L(" maxlength=\"");
     W10_V(max_length);
     W10_L("\"");
   }
 
   if (checked) {
-    W10_L(" checked ");
+    W10_L(" checked");
   }
 
   W10_L(">");
@@ -2036,10 +2049,10 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
  * @param node   [i]   The INPUT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_input_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_input_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -2053,12 +2066,12 @@ s_chtml10_end_input_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The CENTER tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_center_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_center_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2078,12 +2091,12 @@ s_chtml10_start_center_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The CENTER tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_center_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_center_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2103,13 +2116,13 @@ s_chtml10_end_center_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The HR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_hr_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_hr_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2120,13 +2133,8 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
   for (attr = qs_get_attr(doc,node);
        attr; 
        attr = qs_get_next_attr(doc,attr)) {
-
-    char* name;
-    char* value;
-
-    name  = qs_get_attr_name (doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name (doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 'a':
     case 'A':
@@ -2207,12 +2215,11 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
  * @param node   [i]   The HR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_hr_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t* chtml10;
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
-  chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -2226,13 +2233,13 @@ s_chtml10_end_hr_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The IMG tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_img_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_img_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 #ifndef IMG_NOT_CONVERT_FILENAME
   device_table *spec;
 #endif
@@ -2251,13 +2258,8 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-
-    char* name;
-    char* value;
-
-    name  = qs_get_attr_name (doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name (doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 's':
     case 'S':
@@ -2401,9 +2403,7 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
 static char *
 s_chtml10_end_img_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t *chtml10;
-
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -2439,12 +2439,8 @@ s_chtml10_start_select_tag(void *pdoc, Node *child)
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char *nm;
-    char *val;
-
-    nm  = qs_get_attr_name (doc,attr);
-    val = qs_get_attr_value(doc,attr);
-
+    char *nm  = qs_get_attr_name (doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
     switch(*nm) {
     case 's':
     case 'S':
@@ -2481,19 +2477,19 @@ s_chtml10_start_select_tag(void *pdoc, Node *child)
     }
   }
 
-  if (size) {
+  if (size && *size != 0) {
     W10_L(" size=\"");
     W10_V(size);
     W10_L("\"");
   }
 
-  if (name) {
+  if (name && *name != 0) {
     W10_L(" name=\"");
     W10_V(name);
     W10_L("\"");
   }
 
-  W10_L(">\r\n");
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2509,15 +2505,15 @@ s_chtml10_start_select_tag(void *pdoc, Node *child)
 static char *
 s_chtml10_end_select_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml10_t *chtml10;
-  Doc *doc;
+  chtml10_t   *chtml10;
+  Doc         *doc;
   request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("</select>\r\n");
+  W10_L("</select>");
   return chtml10->out;
 }
 
@@ -2533,13 +2529,12 @@ s_chtml10_end_select_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_start_option_tag(void *pdoc, Node *child)
 {
-  chtml10_t *chtml10;
-  Doc *doc;
+  chtml10_t   *chtml10;
+  Doc         *doc;
   request_rec *r;
-  Attr *attr;
-
-  char *selected;
-  char *value;
+  Attr        *attr;
+  char        *selected;
+  char        *value;
 
   chtml10   = GET_CHTML10(pdoc);
   doc       = chtml10->doc;
@@ -2553,12 +2548,8 @@ s_chtml10_start_option_tag(void *pdoc, Node *child)
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char *nm;
-    char *val;
-
-    nm  = qs_get_attr_name (doc,attr);
-    val = qs_get_attr_value(doc,attr);
-
+    char *nm  = qs_get_attr_name (doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
     switch(*nm) {
     case 's':
     case 'S':
@@ -2585,17 +2576,14 @@ s_chtml10_start_option_tag(void *pdoc, Node *child)
     }
   }
 
-  if (value) {
+  if (value && *value != 0) {
     W10_L(" value=\"");
     W10_V(value);
     W10_L("\"");
   }
-  else {
-    W10_L(" value=\"\"");
-  }
 
   if (selected) {
-    W10_L(" selected ");
+    W10_L(" selected");
   }
 
   W10_L(">");
@@ -2614,9 +2602,7 @@ s_chtml10_start_option_tag(void *pdoc, Node *child)
 static char *
 s_chtml10_end_option_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml10_t *chtml10;
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   /* Don't close */
 
@@ -2635,12 +2621,11 @@ s_chtml10_end_option_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_start_div_tag(void *pdoc, Node *child)
 {
-  chtml10_t *chtml10;
-  Doc *doc;
+  chtml10_t   *chtml10;
+  Doc         *doc;
   request_rec *r;
-  Attr *attr;
-
-  char *align;
+  Attr        *attr;
+  char        *align;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2649,17 +2634,11 @@ s_chtml10_start_div_tag(void *pdoc, Node *child)
   align   = NULL;
 
   W10_L("<div");
-
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-
-    char *nm;
-    char *val;
-
-    nm  = qs_get_attr_name(doc,attr);
-    val = qs_get_attr_value(doc,attr);
-
+    char *nm  = qs_get_attr_name(doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
     if (STRCASEEQ('a','A',"align", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 (W3C version 3.2)                                          */
@@ -2692,8 +2671,8 @@ s_chtml10_start_div_tag(void *pdoc, Node *child)
 static char *
 s_chtml10_end_div_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml10_t *chtml10;
-  Doc *doc;
+  chtml10_t   *chtml10;
+  Doc         *doc;
   request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
@@ -2716,9 +2695,9 @@ s_chtml10_end_div_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_chxjif_tag(void *pdoc, Node *node)
 {
-  chtml10_t *chtml10;
-  Doc *doc;
-  Node *child;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  Node        *child;
   request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
@@ -2747,9 +2726,9 @@ s_chtml10_chxjif_tag(void *pdoc, Node *node)
 static char *
 s_chtml10_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc *doc;
+  Doc         *doc;
   request_rec *r;
-  chtml10_t *chtml10;
+  chtml10_t   *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2772,8 +2751,8 @@ s_chtml10_start_pre_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml10_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t *chtml10;
-  Doc *doc;
+  chtml10_t   *chtml10;
+  Doc         *doc;
   request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
@@ -2796,17 +2775,41 @@ s_chtml10_end_pre_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml10_start_p_tag(void *pdoc, Node *UNUSED(node)
+s_chtml10_start_p_tag(void *pdoc, Node *node
 {
-  Doc *doc;
+  Doc         *doc;
   request_rec *r;
-  chtml10_t *chtml10;
+  chtml10_t   *chtml10;
+  Attr        *attr;
+  char        *align = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("<p>");
+  W10_L("<p");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *nm  = qs_get_attr_name(doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", nm)) {
+      /*----------------------------------------------------------------------*/
+      /* CHTML 1.0 (W3C version 3.2)                                          */
+      /*----------------------------------------------------------------------*/
+      if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
+        align = apr_pstrdup(doc->buf.pool, val);
+        break;
+      }
+    }
+  }
+  if (align) {
+    W10_L(" align=\"");
+    W10_V(align);
+    W10_L("\"");
+  }
+
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2822,9 +2825,9 @@ s_chtml10_start_p_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml10_end_p_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc *doc;
+  Doc         *doc;
   request_rec *r;
-  chtml10_t *chtml10;
+  chtml10_t   *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2846,10 +2849,10 @@ s_chtml10_end_p_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_start_textarea_tag(void *pdoc, Node *node) 
 {
-  Doc *doc;
+  Doc         *doc;
   request_rec *r;
-  chtml10_t *chtml10;
-  Attr *attr;
+  chtml10_t   *chtml10;
+  Attr        *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2858,22 +2861,26 @@ s_chtml10_start_textarea_tag(void *pdoc, Node *node)
 
   chtml10->textarea_flag++;
 
-  W10_L("<textarea ");
+  W10_L("<textarea");
 
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-
-    char *name;
-    char *value;
-
-    name  = qs_get_attr_name (doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
+    char *name  = qs_get_attr_name (doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
+    case 'a':
+    case 'A':
+      if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
+        W10_L(" accesskey=\"");
+        W10_V(value);
+        W10_L("\"");
+      }
+      break;
+
     case 'n':
     case 'N':
-      if (strcasecmp(name, "name") == 0) {
+      if (strcasecmp(name, "name") == 0 && value && *value != 0) {
         W10_L(" name=\"");
         W10_V(value);
         W10_L("\"");
@@ -2882,7 +2889,7 @@ s_chtml10_start_textarea_tag(void *pdoc, Node *node)
 
     case 'r':
     case 'R':
-      if (strcasecmp(name, "rows") == 0) {
+      if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
         W10_L(" rows=\"");
         W10_V(value);
         W10_L("\"");
@@ -2891,7 +2898,7 @@ s_chtml10_start_textarea_tag(void *pdoc, Node *node)
 
     case 'c':
     case 'C':
-      if (strcasecmp(name, "cols") == 0) {
+      if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
         W10_L(" cols=\"");
         W10_V(value);
         W10_L("\"");
@@ -2902,8 +2909,7 @@ s_chtml10_start_textarea_tag(void *pdoc, Node *node)
       break;
     }
   }
-
-  W10_L(">\r\n");
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2919,15 +2925,15 @@ s_chtml10_start_textarea_tag(void *pdoc, Node *node)
 static char *
 s_chtml10_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc *doc;
+  Doc         *doc;
   request_rec *r;
-  chtml10_t *chtml10;
+  chtml10_t   *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W10_L("</textarea>\r\n");
+  W10_L("</textarea>");
   chtml10->textarea_flag--;
 
   return chtml10->out;
@@ -2937,25 +2943,24 @@ s_chtml10_end_textarea_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_text(void *pdoc, Node *child)
 {
-  char *textval;
-  char *tmp;
-  char *tdst;
-  char one_byte[2];
-  int ii;
-  int tdst_len;
-  chtml10_t *chtml10;
-  Doc *doc;
+  char        *textval;
+  char        *tmp;
+  char        *tdst;
+  char        one_byte[2];
+  int         ii;
+  int         tdst_len;
+  chtml10_t   *chtml10;
+  Doc         *doc;
   request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
-  
-  textval = qs_get_node_value(doc,child);
-  textval = qs_trim_string(doc->buf.pool, textval);
 
-  if (strlen(textval) == 0)
+  textval = qs_get_node_value(doc,child);
+  if (strlen(textval) == 0) {
     return chtml10->out;
+  }
   
   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
   memset(tmp, 0, qs_get_node_size(doc,child)+1);
@@ -2965,7 +2970,7 @@ s_chtml10_text(void *pdoc, Node *child)
   tdst_len = 0;
   
   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
-    charout;
+    char *out;
     int   rtn;
 
     rtn = s_chtml10_search_emoji(chtml10, &textval[ii], &out);
@@ -3198,6 +3203,99 @@ s_chtml10_end_dd_tag(void *pdoc, Node *UNUSED(child))
   chtml10 = GET_CHTML10(pdoc);
   return chtml10->out;
 }
+
+
+/**
+ * It is a hanmenuer who processes the MENU tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MENU tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml10_start_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<menu>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanmenuer who processes the MENU tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MENU tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml10_end_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
+  Doc *doc = chtml10->doc;
+  W10_L("</menu>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanplaintexter who processes the PLAINTEXT tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PLAINTEXT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml10_start_plaintext_tag(void *pdoc, Node *node)
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<plaintext>");
+  s_chtml10_start_plaintext_tag_inner(pdoc,node);
+  return chtml10->out;
+}
+
+static char *
+s_chtml10_start_plaintext_tag_inner(void *pdoc, Node *node)
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  Node *child;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  for (child = qs_get_child_node(doc, node);
+       child;
+       child = qs_get_next_node(doc, child)) {
+    W10_V(child->otext);
+    s_chtml10_start_plaintext_tag_inner(pdoc, child);
+  }
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanplaintexter who processes the PLAINTEXT tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PLAINTEXT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml10_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
+  return chtml10->out;
+}
 /*
  * vim:ts=2 et
  */