From 4f81b6750f830b2de077d0e935c00611d690b19f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 20:32:07 -0600 Subject: [PATCH] Make cookie header parser more lenient --- basis/http/http-tests.factor | 6 ------ basis/http/parsers/parsers-tests.factor | 16 ++++++++++++++++ basis/http/parsers/parsers.factor | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 basis/http/parsers/parsers-tests.factor diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 229d05615e..2b9cd100f7 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -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 index 0000000000..f87ed47f00 --- /dev/null +++ b/basis/http/parsers/parsers-tests.factor @@ -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 diff --git a/basis/http/parsers/parsers.factor b/basis/http/parsers/parsers.factor index d72147b381..2520c35acb 100644 --- a/basis/http/parsers/parsers.factor +++ b/basis/http/parsers/parsers.factor @@ -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 ) -- 2.34.1