[plt-scheme] Can this possibly be right?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sun Apr 25 01:38:34 EDT 2010

In a more recent version, you won't get an error like that, you'll get
a contract violation:

expected <cookie-value?>, given: ")!"

")!" is definitely not a token, because ) is not allowed.

")!" is definitely not a quoted-string, because it is not wrapped in ".

If we convert it to a quoted form, "\")!\"", then it is still not a
token, because " is not allowed.

That string is then tested with:

(regexp-match?
        #rx"^\"([^\"#\u0000-#\u001F]| |#\return#\newline|#\tab|\\\\\")*\"$" s)

which seems like it should work. However, it may an error in the
regexp engine. A ! character is #\u0021 (which is 2 after #\u001F,
which is not allowed. Maybe some faulty optimization is happening that
breaks it?

What's odd is that

(regexp-match?
        #rx"^\"([^\"#\u0000]| |#\return#\newline|#\tab|\\\\\")*\"$"
        "\")!\"")

succeeds, but

(regexp-match?
        #rx"^\"([^\"#\u0000-#\u0000]| |#\return#\newline|#\tab|\\\\\")*\"$"
        "\")!\"")

and

(regexp-match?
        #rx"^\"([^\"#\u0000-#\u0001]| |#\return#\newline|#\tab|\\\\\")*\"$"
        "\")!\"")

fail.

This seems like a deeper bug than net/cookie, but maybe I'm missing
something obvious.

Jay

On Sat, Apr 24, 2010 at 11:11 PM, Todd O'Bryan <toddobryan at gmail.com> wrote:
> I've either found a bug in net/cookie-unit or I'm very confused.
>
> #lang scheme
> (require web-server/http/cookie)
>
> (make-cookie "name" "value")
> (make-cookie "name" "(")
> (make-cookie "name" "!")
> (make-cookie "name" ")")
> (make-cookie "name" ")!")
> (make-cookie "name" "(!")
> (make-cookie "name" "(!)")
> (make-cookie "name" "!)")
>
> The first four cookies above work fine. The last four raise the error:
>
> could not convert the given string to an acceptable RFC 2109 value
>
> I looked through the code, but I can't see any obvious reason why
> having an exclamation point and a parenthesis in the same string
> should cause an error and I'm pretty sure the RFC doesn't require any
> error here. Any insights?
>
> The offending function is to-rfc2109:value.
>
> Todd
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.