OSDN Git Service

* Added features.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Tue, 18 Mar 2008 06:58:34 +0000 (06:58 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Tue, 18 Mar 2008 06:58:34 +0000 (06:58 +0000)
    - the reservation Query name of softbank can be used.

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/trunk@1890 1a406e8e-add9-4483-a2c8-d8cac5b7c224

include/chxj_jreserved_tag.h [new file with mode: 0644]
sample_site/sf/1.php [new file with mode: 0644]
src/Makefile.am
src/Makefile.in
src/chxj_jhtml.c
src/chxj_jreserved_tag.c [new file with mode: 0644]
src/mod_chxj.c

diff --git a/include/chxj_jreserved_tag.h b/include/chxj_jreserved_tag.h
new file mode 100644 (file)
index 0000000..ffba525
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005 QSDN,Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __CHXJ_JRESERVED_TAG_H__
+#define __CHXJ_JRESERVED_TAG_H__
+
+#define CHXJ_SOFTBANK_RESERVED_TAG_PREFIX "_chxj_sf_"
+
+extern char *chxj_jreserved_to_safe_tag(request_rec *r, const char *src);
+extern char *chxj_safe_to_jreserved_tag(request_rec *r, const char *src);
+#endif
diff --git a/sample_site/sf/1.php b/sample_site/sf/1.php
new file mode 100644 (file)
index 0000000..40640d8
--- /dev/null
@@ -0,0 +1,57 @@
+<html>
+  <head>
+    <title>\83\\83t\83g\83o\83\93\83N\82Ì\97\\96ñ\83N\83G\83\8a\82Ì\83e\83X\83g</title>
+  </head>
+  <body>
+<?php
+echo "POSTDATA<br>";
+var_dump($_POST);
+echo "<hr>";
+echo "GETDATA<br>";
+var_dump($_GET);
+echo "<hr>";
+?>
+<hr>
+<form name="a" method="post" action="1.php">
+  <input type="text" name="pid"   value="pid">
+  <input type="text" name="sid"   value="sid">
+  <input type="text" name="uid"   value="uid">
+  <input type="text" name="lid"   value="lid">
+  <input type="text" name="gid"   value="gid">
+  <input type="text" name="rpid"  value="rpid">
+  <input type="text" name="rsid"  value="rsid">
+  <input type="text" name="nl"    value="nl">
+  <input type="text" name="cl"    value="cl">
+  <input type="text" name="ol"    value="ol">
+  <input type="text" name="pl"    value="pl">
+  <input type="text" name="jskya" value="jskya">
+  <input type="text" name="prc"   value="prc">
+  <input type="text" name="cnt"   value="cnt">
+  <input type="text" name="reg"   value="reg">
+  <input type="text" name="vsekey" value="vsekey">
+  <input type="text" name="vsernk" value="vsernk">
+  <input type="submit">
+</form>
+<hr>
+<form name="a" method="get" action="1.php">
+  <input type="text" name="pid"   value="pid">
+  <input type="text" name="sid"   value="sid">
+  <input type="text" name="uid"   value="uid">
+  <input type="text" name="lid"   value="lid">
+  <input type="text" name="gid"   value="gid">
+  <input type="text" name="rpid"  value="rpid">
+  <input type="text" name="rsid"  value="rsid">
+  <input type="text" name="nl"    value="nl">
+  <input type="text" name="cl"    value="cl">
+  <input type="text" name="ol"    value="ol">
+  <input type="text" name="pl"    value="pl">
+  <input type="text" name="jskya" value="jskya">
+  <input type="text" name="prc"   value="prc">
+  <input type="text" name="cnt"   value="cnt">
+  <input type="text" name="reg"   value="reg">
+  <input type="text" name="vsekey" value="vsekey">
+  <input type="text" name="vsernk" value="vsernk">
+  <input type="submit">
+</form>
+  </body>
+</html>
index 1a9fe2b..4d317da 100644 (file)
@@ -30,7 +30,8 @@ libmod_chxj_la_SOURCES = mod_chxj.c \
     chxj_url_encode.c \
     chxj_cookie.c \
     chxj_preg_replace.c \
-    chxj_emoji.c
+    chxj_emoji.c \
+    chxj_jreserved_tag.c
 
 
 libmod_chxj_la_CFLAGS = $(AM_CFLAGS) -O2 -prefer-pic @QDEFS@ @DDEFS@ -I. -I../include 
index bd605fc..7a6343a 100644 (file)
@@ -74,7 +74,8 @@ am_libmod_chxj_la_OBJECTS = libmod_chxj_la-mod_chxj.lo \
        libmod_chxj_la-chxj_url_encode.lo \
        libmod_chxj_la-chxj_cookie.lo \
        libmod_chxj_la-chxj_preg_replace.lo \
-       libmod_chxj_la-chxj_emoji.lo
+       libmod_chxj_la-chxj_emoji.lo \
+       libmod_chxj_la-chxj_jreserved_tag.lo
 libmod_chxj_la_OBJECTS = $(am_libmod_chxj_la_OBJECTS)
 libmod_chxj_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libmod_chxj_la_CFLAGS) \
@@ -248,7 +249,8 @@ libmod_chxj_la_SOURCES = mod_chxj.c \
     chxj_url_encode.c \
     chxj_cookie.c \
     chxj_preg_replace.c \
-    chxj_emoji.c
+    chxj_emoji.c \
+    chxj_jreserved_tag.c
 
 libmod_chxj_la_CFLAGS = $(AM_CFLAGS) -O2 -prefer-pic @QDEFS@ @DDEFS@ -I. -I../include 
 AM_CFLAGS = @CFLAGS@ -O2 -prefer-pic @QDEFS@ @DDEFS@ -I. -I../include 
@@ -335,6 +337,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_img_conv.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_img_conv_format.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_jhtml.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_jreserved_tag.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_load_device_data.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_load_emoji_data.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_node_convert.Plo@am__quote@
@@ -592,6 +595,13 @@ libmod_chxj_la-chxj_emoji.lo: chxj_emoji.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_emoji.lo `test -f 'chxj_emoji.c' || echo '$(srcdir)/'`chxj_emoji.c
 
+libmod_chxj_la-chxj_jreserved_tag.lo: chxj_jreserved_tag.c
+@am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -MT libmod_chxj_la-chxj_jreserved_tag.lo -MD -MP -MF $(DEPDIR)/libmod_chxj_la-chxj_jreserved_tag.Tpo -c -o libmod_chxj_la-chxj_jreserved_tag.lo `test -f 'chxj_jreserved_tag.c' || echo '$(srcdir)/'`chxj_jreserved_tag.c
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/libmod_chxj_la-chxj_jreserved_tag.Tpo $(DEPDIR)/libmod_chxj_la-chxj_jreserved_tag.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='chxj_jreserved_tag.c' object='libmod_chxj_la-chxj_jreserved_tag.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_jreserved_tag.lo `test -f 'chxj_jreserved_tag.c' || echo '$(srcdir)/'`chxj_jreserved_tag.c
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index eb2d043..9b5bce0 100644 (file)
@@ -1464,7 +1464,7 @@ s_jhtml_start_input_tag(void *pdoc, Node *node)
     jhtml->out = apr_pstrcat(r->pool, 
                     jhtml->out, 
                     " name=\"", 
-                    name, 
+                    chxj_jreserved_to_safe_tag(r, name),
                     "\" ", 
                     NULL);
   }
@@ -2378,7 +2378,7 @@ s_jhtml_start_textarea_tag(void *pdoc, Node *node)
     value = qs_get_attr_value(doc,attr);
 
     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
-      jhtml->out = apr_pstrcat(r->pool, jhtml->out, " name=\"",value,"\"", NULL);
+      jhtml->out = apr_pstrcat(r->pool, jhtml->out, " name=\"",chxj_jreserved_to_safe_tag(r, value),"\"", NULL);
     }
     else 
     if ((*name == 'r' || *name == 'R') && strcasecmp(name, "rows") == 0) {
diff --git a/src/chxj_jreserved_tag.c b/src/chxj_jreserved_tag.c
new file mode 100644 (file)
index 0000000..9abbef5
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005 QSDN,Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "mod_chxj.h"
+#include "chxj_jreserved_tag.h"
+
+typedef struct r_table {
+  char lower;
+  char upper;
+  char *name;
+} r_table_t;
+
+static r_table_t reserved_start_with_table[] = {
+  {
+    .lower = 'j',
+    .upper = 'J',
+    .name  = "jsky",
+  },
+};
+
+
+#define RESERVED_NELT            (16)
+#define RESERVED_NELT_START_WITH (1)
+
+static r_table_t reserved_table[] = {
+  {
+    .lower = 'p',
+    .upper = 'P',
+    .name = "pid",
+  },
+  {
+    .lower = 's',
+    .upper = 'S',
+    .name = "sid",
+  },
+  { 
+    .lower = 'u',
+    .upper = 'U',
+    .name  = "uid",
+  },
+  {
+    .lower = 'l',
+    .upper = 'L',
+    .name  = "lid",
+  },
+  {
+    .lower = 'g',
+    .upper = 'G',
+    .name  = "gid",
+  },
+  {
+    .lower = 'r',
+    .upper = 'R',
+    .name  = "rpid",
+  },
+  {
+    .lower = 'r',
+    .upper = 'R',
+    .name  = "rsid",
+  },
+  {
+    .lower = 'n',
+    .upper = 'N',
+    .name  = "nl",
+  },
+  {
+    .lower = 'c',
+    .upper = 'C',
+    .name  = "cl",
+  },
+  {
+    .lower = 'o',
+    .upper = 'O',
+    .name  = "ol",
+  },
+  {
+    .lower = 'p',
+    .upper = 'P',
+    .name  = "pl",
+  },
+  {
+    .lower = 'p',
+    .upper = 'P',
+    .name  = "prc",
+  },
+  {
+    .lower = 'c',
+    .upper = 'C',
+    .name  = "cnt",
+  },
+  {
+    .lower = 'r',
+    .upper = 'R',
+    .name  = "reg",
+  },
+  {
+    .lower = 'v',
+    .upper = 'V',
+    .name  = "vsekey",
+  },
+  {
+    .lower = 'v',
+    .upper = 'V',
+    .name  = "vsernk",
+  },
+};
+
+
+char *
+chxj_jreserved_to_safe_tag(request_rec *r, const char *src)
+{
+  int ii;
+  for (ii=0;ii<RESERVED_NELT;ii++) {
+    if (STRCASEEQ(reserved_table[ii].lower,
+                  reserved_table[ii].upper,
+                  reserved_table[ii].name, 
+                  src)) {
+      return apr_psprintf(r->pool, "%s%s", CHXJ_SOFTBANK_RESERVED_TAG_PREFIX, reserved_table[ii].name);
+    }
+  }
+  for (ii=0; ii<RESERVED_NELT_START_WITH; ii++) {
+    if (strncasecmp(reserved_start_with_table[ii].name, src, sizeof(reserved_start_with_table[ii].name)) == 0) {
+      return apr_psprintf(r->pool, "%s%s", CHXJ_SOFTBANK_RESERVED_TAG_PREFIX, src);
+    }
+  }
+  return (char *)src;
+}
+
+
+char *
+chxj_safe_to_jreserved_tag(request_rec *r, const char *src)
+{
+  if (strncasecmp(CHXJ_SOFTBANK_RESERVED_TAG_PREFIX, src, sizeof(CHXJ_SOFTBANK_RESERVED_TAG_PREFIX)-1) == 0) {
+    return apr_pstrdup(r->pool, &src[sizeof(CHXJ_SOFTBANK_RESERVED_TAG_PREFIX)-1]);
+  }
+  return (char *)src;
+}
index e9af58f..826d4f8 100644 (file)
@@ -60,6 +60,7 @@
 #include "chxj_url_encode.h"
 #include "chxj_str_util.h"
 #include "chxj_emoji.h"
+#include "chxj_jreserved_tag.h"
 
 
 #define CHXJ_VERSION_PREFIX PACKAGE_NAME "/"
@@ -474,6 +475,8 @@ chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp, device_tabl
 
     name  = apr_strtok(pair, "=", &vstate);
     value = apr_strtok(NULL, "=", &vstate);
+    name = chxj_safe_to_jreserved_tag(r, name);
+
     if (strncasecmp(name, "_chxj", 5) != 0) {
       if (strlen(result) != 0) 
         result = apr_pstrcat(r->pool, result, "&", NULL);
@@ -624,6 +627,8 @@ chxj_input_convert(
 
     name  = apr_strtok(pair, "=", &vstate);
     value = apr_strtok(NULL, "=", &vstate);
+    name  = chxj_safe_to_jreserved_tag(r, name);
+
     if (strncasecmp(name, "_chxj", 5) != 0) {
       result = chxj_convert_emoji_param_list(r, spec, entryp, result, name, value, func_emoji_to_meta_emoji);
       DBG(r, "result:[%s]", result);