Griffin.WebServer icon indicating copy to clipboard operation
Griffin.WebServer copied to clipboard

CookieParser bug: _index, _cookieValue and _cookieName not reset in Parse(...)

Open henon opened this issue 9 years ago • 1 comments

_index, _cookieValue and _cookieName have to be set to 0, "" and "" respectively at the start of Parse(...) method or only the first cookie parsing will yield correct result.

henon avatar Aug 06 '16 19:08 henon

Here is the fix for that issue in HttpCookieParser change the Parse method to

    /// <summary>
    /// Parse cookie string
    /// </summary>
    /// <returns>A generated cookie collection.</returns>
    public IHttpCookieCollection<IHttpCookie> Parse(string value)
    {
        _index = 0;
        _cookieValue = "";
        _cookieName = "";
        if (value == null) throw new ArgumentNullException("value");
        _headerValue = value;
        _cookies = new HttpCookieCollection<IHttpCookie>();
        _parserMethod = Name_Before;

        while (!IsEOF)
        {
            _parserMethod();
        }

        OnCookie(_cookieName, _cookieValue);
        return _cookies;
    }

henon avatar Oct 05 '16 06:10 henon