Re: [http-state] non-ASCII cookie values (was Re: Closing Ticket 3: Public Suffixes)

Maciej Stachowiak <> Tue, 02 February 2010 01:24 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 6A23E3A693E for <>; Mon, 1 Feb 2010 17:24:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -106.599
X-Spam-Status: No, score=-106.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id RB2fgPnG19gl for <>; Mon, 1 Feb 2010 17:24:29 -0800 (PST)
Received: from ( []) by (Postfix) with ESMTP id 93A1C3A6767 for <>; Mon, 1 Feb 2010 17:24:29 -0800 (PST)
Received: from ( []) by (Postfix) with ESMTP id E918389B2B66 for <>; Mon, 1 Feb 2010 17:25:05 -0800 (PST)
X-AuditID: 11807137-b7bd4ae000000f0d-af-4b677ef1434a
Received: from ( []) by (Apple SCV relay) with SMTP id 00.33.03853.1FE776B4; Mon, 1 Feb 2010 17:25:05 -0800 (PST)
MIME-version: 1.0
Content-transfer-encoding: 7bit
Content-type: text/plain; charset="us-ascii"
Received: from [] by (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <> for; Mon, 01 Feb 2010 17:25:05 -0800 (PST)
From: Maciej Stachowiak <>
In-reply-to: <>
Date: Mon, 01 Feb 2010 17:25:05 -0800
Message-id: <>
References: <>
To: Adam Barth <>
X-Mailer: Apple Mail (2.1077)
X-Brightmail-Tracker: AAAAAQAAAZE=
Cc: eric bianchetti <>,
Subject: Re: [http-state] non-ASCII cookie values (was Re: Closing Ticket 3: Public Suffixes)
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discuss HTTP State Management Mechanism <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 02 Feb 2010 01:24:30 -0000

On Feb 1, 2010, at 10:14 AM, Adam Barth wrote:

> On Sun, Jan 31, 2010 at 2:37 PM, eric bianchetti
> <> wrote:
>> That part does not please :
>> The cookie-value is opaque to the user agent and MAY be anything the
>>    origin server chooses to send, possibly in a server-selected
>>    printable ASCII encoding.
>> Livng and working in a non ASCII country, I tend to think we shall prepare for the coming of the other languages (Thai, Chines, Korean ....), IF a person get a cookie from a Thai server , can we securely suppose that person(computer) went to a thai site, and that person is using Thai on a daily basis? (Replace Thai by any multi bytes languages).
> The part of that sentence after the "possibly" doesn't haven any
> normative force (it's just advice that the server can take or leave).
> I can remove the reference to ASCII here if you like.  Julian please
> correct me if I'm wrong, but I believe that HTTP headers typically
> contain only ASCII characters.

We do have to define what happens if there are non-ASCII characters in a header value. Presumably, if such bytes are set via Set-Cookie, then the Cookie header just echoes them back, so we can treat them as opaque. (That's assuming there is no requirement to reject non-ASCII cookie values.) But there are two ways in which it matters:

1) A header with non-ASCII bytes get set via Set-Cookie, then read through a JS API such as document.cookie. document.cookie gives a UTF-16 encoded string, so at this point the server has to decide how to interpret non-ASCII bytes in the cookie value.

2) If you set a cookie via document.cookie and include non-ASCII characters in the value, what bytes get sent?