Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double-encoded cookies #3575

Closed
elacuesta opened this issue Jan 10, 2019 · 1 comment · Fixed by #2400
Closed

Double-encoded cookies #3575

elacuesta opened this issue Jan 10, 2019 · 1 comment · Fixed by #2400
Labels

Comments

@elacuesta
Copy link
Member

When cookies are passed as UTF8 encoded bytes to the Request constructor, they end up being encoded twice and escaped in the Cookie header.

$ scrapy shell
(...)
In [1]: fetch(scrapy.Request('https://httpbin.org/cookies', cookies={'a': u'á'.encode('utf8')}))

In [2]: request.headers['Cookie']
Out[2]: b"a=b'\\xc3\\xa1'"

In [3]: print(response.text)
{
  "cookies": {
    "a": "b'\\xc3\\xa1'"
  }
}

This seems to happen only in Python 3.

$ scrapy version -v
Scrapy       : 1.5.0
lxml         : 4.2.6.0
libxml2      : 2.9.8
cssselect    : 1.0.3
parsel       : 1.5.1
w3lib        : 1.19.0
Twisted      : 18.9.0
Python       : 3.6.0 (default, Sep  1 2017, 10:59:37) - [GCC 4.8.4]
pyOpenSSL    : 18.0.0 (OpenSSL 1.1.0j  20 Nov 2018)
cryptography : 2.4.2
Platform     : Linux-4.4.0-134-generic-x86_64-with-debian-jessie-sid
@elacuesta
Copy link
Member Author

This is fixed by #2400

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

Successfully merging a pull request may close this issue.

2 participants