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 44dac77..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))
@@ -366,6 +367,16 @@ tag_handler chtml10_handler[] = {
     s_chtml10_start_plaintext_tag,
     s_chtml10_end_plaintext_tag,
   },
+  /* tagBLINK */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagMARQUEE */
+  {
+    NULL,
+    NULL,
+  },
 };
 
 
@@ -378,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;
@@ -460,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;
 }
@@ -478,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));
@@ -507,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;
@@ -560,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;
@@ -588,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);
@@ -614,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 */
 
@@ -635,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;
 }
@@ -654,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;
@@ -679,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;
@@ -704,12 +711,12 @@ 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;
@@ -729,12 +736,12 @@ 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;
@@ -754,12 +761,12 @@ 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;
@@ -779,12 +786,12 @@ 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;
@@ -804,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;
@@ -829,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;
 }
 
@@ -846,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;
@@ -862,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=\"");
@@ -889,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;
@@ -914,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;
@@ -957,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;
@@ -998,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=\"");
@@ -1025,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;
@@ -1093,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;
@@ -1121,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;
@@ -1134,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=\"");
@@ -1161,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;
@@ -1202,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=\"");
@@ -1232,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;
@@ -1254,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;
@@ -1279,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;
@@ -1304,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;
@@ -1324,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);
@@ -1351,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;
 }
@@ -1368,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;
@@ -1390,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':
@@ -1464,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;
@@ -1509,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':
@@ -1705,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=\"");
@@ -1836,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                                                           */
@@ -1849,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':
@@ -1862,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;
 
@@ -1877,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;
 
@@ -1898,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;
 }
@@ -1912,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;
@@ -1937,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;
@@ -2009,7 +2007,7 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
 
   if (value && *value != 0) {
     W10_L(" value=\"");
-    W10_V(value);
+    W10_V(chxj_add_slash_to_doublequote(doc->pool,value));
     W10_L("\"");
   }
 
@@ -2051,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;
 }
@@ -2068,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;
@@ -2093,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;
@@ -2118,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;
@@ -2135,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':
@@ -2222,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;
 }
@@ -2241,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
@@ -2266,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':
@@ -2416,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;
 }
@@ -2454,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':
@@ -2524,8 +2505,8 @@ 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);
@@ -2548,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;
@@ -2568,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':
@@ -2626,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 */
 
@@ -2647,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;
@@ -2661,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)                                          */
@@ -2704,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);
@@ -2728,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);
@@ -2759,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;
@@ -2784,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);
@@ -2810,11 +2777,11 @@ s_chtml10_end_pre_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_start_p_tag(void *pdoc, Node *node) 
 {
-  Doc *doc;
+  Doc         *doc;
   request_rec *r;
-  chtml10_t *chtml10;
-  Attr *attr;
-  char *align = NULL;
+  chtml10_t   *chtml10;
+  Attr        *attr;
+  char        *align = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2858,9 +2825,9 @@ s_chtml10_start_p_tag(void *pdoc, Node *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;
@@ -2882,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;
@@ -2899,13 +2866,8 @@ s_chtml10_start_textarea_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':
@@ -2947,7 +2909,6 @@ s_chtml10_start_textarea_tag(void *pdoc, Node *node)
       break;
     }
   }
-
   W10_L(">");
   return chtml10->out;
 }
@@ -2964,9 +2925,9 @@ 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;
@@ -2982,14 +2943,14 @@ 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);
@@ -2997,10 +2958,6 @@ s_chtml10_text(void *pdoc, Node *child)
   r       = doc->r;
 
   textval = qs_get_node_value(doc,child);
-#if 0
-  textval = qs_trim_string(doc->buf.pool, textval);
-#endif
-
   if (strlen(textval) == 0) {
     return chtml10->out;
   }