Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

cookie value have a blank space will cause get a truncated value; #7

Closed
guanglinlv opened this issue Jan 27, 2015 · 2 comments
Closed

Comments

@guanglinlv
Copy link

local cookie = require "resty.http_cookie"
local coo = cookie:new()

coo:set({key="test",value="test value"})

next request ,i use coo:get("test") ,it will return "test" not "test value";

        if state == EXPECT_KEY then
            if byte(text_cookie, j) == EQUAL then
                key = sub(text_cookie, i, j - 1)
                state = EXPECT_VALUE
                i = j + 1
            end
        elseif state == EXPECT_VALUE then
            if byte(text_cookie, j) == SEMICOLON
                    --this is the reason code,it use SPACE OR HTAB as a separator,why?
                    or byte(text_cookie, j) == SPACE
                    or byte(text_cookie, j) == HTAB
            then
                value = sub(text_cookie, i, j - 1)
                cookie_table[key] = value
                cnt = cnt + 1
            end
                key, value = nil, nil
                state = EXPECT_SP
                i = j + 1
            end
        elseif state == EXPECT_SP then
@calio
Copy link
Contributor

calio commented Jan 27, 2015

This is the same as #6. Using SPACE and HTAB as a separator is because RFC doesn't allow spaces in cookie value. See http://tools.ietf.org/search/rfc6265#section-4.2.1

@guanglinlv
Copy link
Author

oh,i had read and study the RFC6265#section-4.2.1,thank you for replying my questions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants