From 96a3f47ea09e9e8beb11fbf26ba3138a6a289a4f Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 27 Apr 2010 08:48:07 -0600 Subject: [PATCH] Fixing cookie regex --- collects/net/cookie-unit.ss | 2 +- collects/tests/net/cookie.ss | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/collects/net/cookie-unit.ss b/collects/net/cookie-unit.ss index 64ff59509b..dd3342410c 100644 --- a/collects/net/cookie-unit.ss +++ b/collects/net/cookie-unit.ss @@ -255,7 +255,7 @@ ;; appear as a block to be legal, and " may only appear as \" (define (rfc2068:quoted-string? s) (and (regexp-match? - #rx"^\"([^\"#\u0000-#\u001F]| |#\return#\newline|#\tab|\\\\\")*\"$" + #rx"^\"([^\"\u0000-\u001F]| |\r\n|\t|\\\\\")*\"$" s) s)) diff --git a/collects/tests/net/cookie.ss b/collects/tests/net/cookie.ss index 601eb3d71f..57200a5927 100644 --- a/collects/tests/net/cookie.ss +++ b/collects/tests/net/cookie.ss @@ -19,12 +19,12 @@ (syntax-rules () [(o/* x) x] [(o/* x f g ...) (f (o/* x g ...))])) - + (define (tests) - + ;; test the most basic functionality (cookie-test (λ (x) x) "a=b; Version=1") - + ;; test each modifier individually (cookie-test (RC cookie:add-comment "set+a+to+b") "a=b; Comment=set+a+to+b; Version=1") @@ -54,7 +54,7 @@ "a=b; Version=1") (cookie-test (RC cookie:version 12) "a=b; Version=12") - + ;; test combinations (cookie-test (o (RC cookie:add-comment "set+a+to+b") (RC cookie:add-domain ".example.net")) @@ -66,7 +66,7 @@ (RC cookie:version 10) (RC cookie:add-max-age 20)) "a=b; Max-Age=20; Path=\"/whatever/wherever/\"; Version=10") - + ;; test error cases (let () (define-syntax cookie-error-test @@ -78,7 +78,18 @@ (cookie-error-test (RC cookie:add-domain "doesntstartwithadot.example.com")) (cookie-error-test (RC cookie:add-domain "bad domain.com")) (cookie-error-test (RC cookie:add-domain ".bad-domain;com"))) - + + ; cookie value + (test + (cookie-value? "value") + (cookie-value? "(") + (cookie-value? "!") + (cookie-value? ")") + (cookie-value? ")!") + (cookie-value? "(!") + (cookie-value? "(!)") + (cookie-value? "!)")) + ) - + (test do (tests)))