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

Error when cookies contain double quotes #711

Open
na-- opened this issue Jul 16, 2018 · 5 comments
Open

Error when cookies contain double quotes #711

na-- opened this issue Jul 16, 2018 · 5 comments
Labels
bug new-http issues that would require (or benefit from) a new HTTP API

Comments

@na--
Copy link
Member

na-- commented Jul 16, 2018

While testing something else, I stumbled on a small bug with double quotes in cookie values... The following code:

import http from 'k6/http';

export default function () {
	let resp = http.get("https://httpbingo.org/cookies", {
		"cookies": {
			"test": "\""
		},
	})
	console.log(resp.body);
}

produces this... warning?:

2018/07/16 10:18:33 net/http: invalid byte '"' in Cookie.Value; dropping invalid bytes

It seems that for some reason, the Go standard library logs this directly, which is super annoying... Skimming some golang issues, it's not exactly clear how we should escape those values...

@ofauchon
Copy link
Contributor

Hello,

Same problem for me !

The application I test uses double quoted cookies values with separators + uppercase headers

Cookie: foo-boa="DATA-NET-CMP:1234564:123456789789798AEZEAZEA:zzzX"
SPECIFIC-HEADER=jfdislfjsdi

I ended up patching net/* go sources to make it permissive :-(

  • Removed cookie/headers sanitization .

Although it' dirty hacks, I didn't find any elegant way to do it.

Olivier

@na--
Copy link
Member Author

na-- commented Jul 24, 2018

Yeah, when I posted this issue I skimmed a bunch of golang github issues and discussions and I don't think I saw a nice way to work around this...

@tkanos
Copy link

tkanos commented Oct 9, 2018

you can also get the cookie directly from the r.header["cookie"] and parse it yourself but it's not elegant neither.

@nishant-shah-social
Copy link

Hello All,
Is there any workaround to this?
I am currently blocked because of this issue. We need to set a cookie in our performance test script whose value contains double quotes and its getting escaped :(

@rbayliss
Copy link

Try URL encoding the string as a workaround. Eg:

http.cookieJar().set('https://www.google.com', 'my_cookie', encodeURIComponent("\"I have quotes!\""));

@mstoykov mstoykov added the new-http issues that would require (or benefit from) a new HTTP API label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new-http issues that would require (or benefit from) a new HTTP API
Projects
None yet
Development

No branches or pull requests

6 participants