Make cookie parsing more permissive
parent
b045a39333
commit
6297c4d2e4
|
@ -2,7 +2,7 @@ USING: http http.server http.client tools.test multiline
|
||||||
io.streams.string io.encodings.utf8 io.encodings.8-bit
|
io.streams.string io.encodings.utf8 io.encodings.8-bit
|
||||||
io.encodings.binary io.encodings.string kernel arrays splitting
|
io.encodings.binary io.encodings.string kernel arrays splitting
|
||||||
sequences assocs io.sockets db db.sqlite continuations urls
|
sequences assocs io.sockets db db.sqlite continuations urls
|
||||||
hashtables accessors ;
|
hashtables accessors namespaces ;
|
||||||
IN: http.tests
|
IN: http.tests
|
||||||
|
|
||||||
[ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
|
[ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
|
||||||
|
@ -11,6 +11,12 @@ IN: http.tests
|
||||||
|
|
||||||
[ "application/octet-stream" binary ] [ "application/octet-stream" parse-content-type ] unit-test
|
[ "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 ;
|
: lf>crlf "\n" split "\r\n" join ;
|
||||||
|
|
||||||
STRING: read-request-test-1
|
STRING: read-request-test-1
|
||||||
|
@ -126,6 +132,7 @@ content-type: text/html; charset=UTF-8
|
||||||
;
|
;
|
||||||
|
|
||||||
read-response-test-1' 1array [
|
read-response-test-1' 1array [
|
||||||
|
URL" http://localhost/" url set
|
||||||
read-response-test-1 lf>crlf
|
read-response-test-1 lf>crlf
|
||||||
[ read-response ] with-string-reader
|
[ read-response ] with-string-reader
|
||||||
[ write-response ] with-string-writer
|
[ write-response ] with-string-writer
|
||||||
|
|
|
@ -142,16 +142,15 @@ PEG: parse-header-line ( string -- pair )
|
||||||
'space' ,
|
'space' ,
|
||||||
'attr' ,
|
'attr' ,
|
||||||
'space' ,
|
'space' ,
|
||||||
[ "=" token , 'space' , 'value' , ] seq* [ peek ] action
|
[ "=" token , 'space' , 'value' , ] seq* [ peek ] action optional ,
|
||||||
epsilon [ drop f ] action
|
|
||||||
2choice ,
|
|
||||||
'space' ,
|
'space' ,
|
||||||
] seq* ;
|
] seq* ;
|
||||||
|
|
||||||
: 'av-pairs' ( -- parser )
|
: 'av-pairs' ( -- parser )
|
||||||
'av-pair' ";" token list-of optional ;
|
'av-pair' ";" token list-of optional ;
|
||||||
|
|
||||||
PEG: (parse-set-cookie) ( string -- alist ) 'av-pairs' just ;
|
PEG: (parse-set-cookie) ( string -- alist )
|
||||||
|
'av-pairs' just [ sift ] action ;
|
||||||
|
|
||||||
: 'cookie-value' ( -- parser )
|
: 'cookie-value' ( -- parser )
|
||||||
[
|
[
|
||||||
|
@ -162,7 +161,10 @@ PEG: (parse-set-cookie) ( string -- alist ) 'av-pairs' just ;
|
||||||
'space' ,
|
'space' ,
|
||||||
'value' ,
|
'value' ,
|
||||||
'space' ,
|
'space' ,
|
||||||
] seq* ;
|
] seq*
|
||||||
|
[ ";,=" member? not ] satisfy repeat1 [ drop f ] action
|
||||||
|
2choice ;
|
||||||
|
|
||||||
PEG: (parse-cookie) ( string -- alist )
|
PEG: (parse-cookie) ( string -- alist )
|
||||||
'cookie-value' [ ";," member? ] satisfy list-of optional just ;
|
'cookie-value' [ ";," member? ] satisfy list-of
|
||||||
|
optional just [ sift ] action ;
|
||||||
|
|
Loading…
Reference in New Issue