OSDN Git Service

STRICT_FORMVAR hack.
authorvisor <visor@users.sourceforge.jp>
Mon, 14 May 2012 14:29:00 +0000 (23:29 +0900)
committervisor <visor@users.sourceforge.jp>
Mon, 14 May 2012 14:29:00 +0000 (23:29 +0900)
lib/form.cc

index cb383d7..66dd297 100644 (file)
@@ -10,6 +10,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+//#define STRICT_FORMVAR       0
+
 void  CGIForm::parseURLEncoded (const ustring& query) {
     ustring::size_type  s, e, t;
     uiterator  ib, ie;
@@ -166,21 +168,26 @@ size_t  CGIForm::atSize (map_t& mp, const ustring& name) {
 int  CGIForm::insert (map_t& mp, const ustring& name, const ustring& value) {
     int  ans = -1;
 
-    if (checkName (name)) {
-       map_t::iterator  it = mp.find (name);
-       std::vector<int>*  v;
-       
-       if (it == mp.end ()) {
-           v = insertName (mp, name);
-       } else {
-           v = &index.at (it->second);
-       }
-       if (v) {
-           ans = values.size ();
-           values.push_back (value);
-           v->push_back (ans);
+#ifdef STRICT_FORMVAR
+    if (checkName (name))
+#else
+    if (name.length () > 0 && name.length () < 64)
+#endif
+       {
+           map_t::iterator  it = mp.find (name);
+           std::vector<int>*  v;
+           
+           if (it == mp.end ()) {
+               v = insertName (mp, name);
+           } else {
+               v = &index.at (it->second);
+           }
+           if (v) {
+               ans = values.size ();
+               values.push_back (value);
+               v->push_back (ans);
+           }
        }
-    }
     return ans;
 }