OSDN Git Service

fix empty value cookie condition.
authorornse01 <ornse01@users.sourceforge.jp>
Mon, 16 Mar 2015 14:49:04 +0000 (14:49 +0000)
committerornse01 <ornse01@users.sourceforge.jp>
Mon, 16 Mar 2015 14:49:04 +0000 (14:49 +0000)
git-svn-id: http://svn.sourceforge.jp/svnroot/bchan/bchan/trunk@663 20a0b8eb-f62a-4a12-8fe1-b598822500fb

src/cookiedb.c
src/test_cookiedb.c

index a27a3b4..71de7c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * cookiedb.c
  *
- * Copyright (c) 2011 project bchan
+ * Copyright (c) 2011-2015 project bchan
  *
  * This software is provided 'as-is', without any express or implied
  * warranty. In no event will the authors be held liable for any damages
@@ -182,9 +182,6 @@ LOCAL Bool httpcookie_isvalueset(httpcookie_t *cookie)
        if (cookie->attr.len == 0) {
                return False;
        }
-       if (cookie->name.len == 0) {
-               return False;
-       }
        return True;
 }
 
@@ -1248,9 +1245,6 @@ LOCAL Bool cookiedb_readfilecontext_cookiecheck(httpcookie_t *cookie)
        if (cookie->attr.len == 0) {
                return False;
        }
-       if (cookie->name.len == 0) {
-               return False;
-       }
        if (cookie->persistent == False) {
                return False;
        }
index fb7d797..3420836 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * test_cookiedb.c
  *
- * Copyright (c) 2011-2012 project bchan
+ * Copyright (c) 2011-2015 project bchan
  *
  * This software is provided 'as-is', without any express or implied
  * warranty. In no event will the authors be held liable for any damages
@@ -2871,6 +2871,77 @@ LOCAL UNITTEST_RESULT test_cookiedb_52()
        return test_cookiedb_testingseparateinput_file_clear(data, 2, 0x1eec16c0, NULL, 0, "2ch.net", "/", False, 0x1eec16c0, expected, 0);
 }
 
+/* empty value test */
+
+LOCAL UNITTEST_RESULT test_cookiedb_53()
+{
+       testcookie_input_t data[] = {
+               {
+                       "0ch.net", /* origin_host */
+                       "/", /* origin_path */
+                       "PON", /* name */
+                       "", /* value */
+                       NULL, /* domain */
+                       NULL, /* path */
+                       False, /* secure */
+                       0 /* expires */
+               },
+               {
+                       "0ch.net", /* origin_host */
+                       "/", /* origin_path */
+                       "HAP", /* name */
+                       NULL, /* value */
+                       NULL, /* domain */
+                       NULL, /* path */
+                       False, /* secure */
+                       0 /* expires */
+               },
+       };
+       testcookie_expected_t expected[] = {
+               {
+                       "PON", /* name */
+                       "", /* value */
+               },
+               {
+                       "HAP", /* name */
+                       "", /* value */
+               }
+       };
+
+       return test_cookiedb_testingseparateinput(data, 2, 0x1eec16c0, "0ch.net", "/", False, 0x1eec16c0, expected, 2);
+}
+
+/* empty value test with cookiedb_readfile() */
+
+LOCAL UNITTEST_RESULT test_cookiedb_54()
+{
+       testcookie_input_t data[] = {
+               {
+                       "0ch.net", /* origin_host */
+                       "/", /* origin_path */
+                       "AAA", /* name */
+                       "BBB", /* value */
+                       NULL, /* domain */
+                       NULL, /* path */
+                       False, /* secure */
+                       0 /* expires */
+               },
+       };
+       UB filedata[] = {"0ch.net<>/<>III<><>comment<><>1300000000<><><><>\n"};
+       testcookie_expected_t expected[] = {
+               {
+                       "AAA", /* name */
+                       "BBB", /* value */
+               },
+               {
+                       "III", /* name */
+                       "", /* value */
+               }
+       };
+
+       return test_cookiedb_testingseparateinput_file(data, 1, 0x0eec16c0, filedata, strlen(filedata), "0ch.net", "/", False, 0x0eec16c0, expected, 2);
+}
+
 EXPORT VOID test_cookiedb_main(unittest_driver_t *driver)
 {
        UNITTEST_DRIVER_REGIST(driver, test_cookiedb_1);
@@ -2925,4 +2996,6 @@ EXPORT VOID test_cookiedb_main(unittest_driver_t *driver)
        UNITTEST_DRIVER_REGIST(driver, test_cookiedb_50);
        UNITTEST_DRIVER_REGIST(driver, test_cookiedb_51);
        UNITTEST_DRIVER_REGIST(driver, test_cookiedb_52);
+       UNITTEST_DRIVER_REGIST(driver, test_cookiedb_53);
+       UNITTEST_DRIVER_REGIST(driver, test_cookiedb_54);
 }