]> gitweb.factorcode.org Git - factor.git/commitdiff
Make cookie header parser more lenient
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 8 Mar 2009 02:32:07 +0000 (20:32 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 8 Mar 2009 02:32:07 +0000 (20:32 -0600)
basis/http/http-tests.factor
basis/http/parsers/parsers-tests.factor [new file with mode: 0644]
basis/http/parsers/parsers.factor

index 229d05615ece724efdc3256e626cd2f7cd2c121f..2b9cd100f73ff8be255d88849a07fc7b14db9aa3 100644 (file)
@@ -11,12 +11,6 @@ IN: http.tests
 
 [ "application/octet-stream" binary ] [ "application/octet-stream" parse-content-type ] unit-test
 
-[ { } ] [ "" parse-cookie ] unit-test
-[ { } ] [ "" parse-set-cookie ] unit-test
-
-! Make sure that totally invalid cookies don't confuse us
-[ { } ] [ "hello world; how are you" parse-cookie ] unit-test
-
 : lf>crlf "\n" split "\r\n" join ;
 
 STRING: read-request-test-1
diff --git a/basis/http/parsers/parsers-tests.factor b/basis/http/parsers/parsers-tests.factor
new file mode 100644 (file)
index 0000000..f87ed47
--- /dev/null
@@ -0,0 +1,16 @@
+IN: http.parsers.tests
+USING: http http.parsers tools.test ;
+
+[ { } ] [ "" parse-cookie ] unit-test
+[ { } ] [ "" parse-set-cookie ] unit-test
+
+! Make sure that totally invalid cookies don't confuse us
+[ { } ] [ "hello world; how are you" parse-cookie ] unit-test
+
+[ { T{ cookie { name "__s" } { value "12345567" } } } ]
+[ "__s=12345567" parse-cookie ]
+unit-test
+
+[ { T{ cookie { name "__s" } { value "12345567" } } } ]
+[ "__s=12345567;" parse-cookie ]
+unit-test
\ No newline at end of file
index d72147b3813caa854edae9b2d339cd18ad3f8b3c..2520c35acb9b215eb6fedb5e36bcdd63f8e6fdda 100644 (file)
@@ -162,7 +162,7 @@ PEG: (parse-set-cookie) ( string -- alist )
         'value' ,
         'space' ,
     ] seq*
-    [ ";,=" member? not ] satisfy repeat1 [ drop f ] action
+    [ ";,=" member? not ] satisfy repeat0 [ drop f ] action
     2choice ;
 
 PEG: (parse-cookie) ( string -- alist )