Skip to content

WebTestClientRequestConverter mishandles cookies whose value contains =#1040

Open
config25 wants to merge 1 commit intospring-projects:3.0.xfrom
config25:fix/cookie-equals-sign-parsing
Open

WebTestClientRequestConverter mishandles cookies whose value contains =#1040
config25 wants to merge 1 commit intospring-projects:3.0.xfrom
config25:fix/cookie-equals-sign-parsing

Conversation

@config25
Copy link
Copy Markdown
Contributor

WebTestClientRequestConverter.createRequestCookie() uses split("=") to
parse cookie headers. This causes two problems:

  • Cookie values containing = (e.g. Base64-padded values like YWJjZGVm==)
    are silently truncated at the first =
  • Cookie headers without = throw ArrayIndexOutOfBoundsException

Replace split("=") with indexOf('=') to split on only the first = and
handle the no-= case by returning an empty value.

Fixes gh-1038

base branch 3.0.x

@config25 config25 force-pushed the fix/cookie-equals-sign-parsing branch from 4cf5c5a to ac1b011 Compare April 13, 2026 01:33
@wilkinsona wilkinsona changed the title Fix cookie parsing when value contains equals sign WebTestClientRequestConverter mishandles cookies whose value contains = and fails on cookie headers without = Apr 13, 2026
@wilkinsona wilkinsona added type: bug A bug and removed status: waiting-for-triage Untriaged issue labels Apr 13, 2026
@wilkinsona wilkinsona added this to the 3.0.x milestone Apr 13, 2026
}

@Test
void requestWithCookieValueContainingEqualsSign() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has to be public as the 3.0.x branch uses JUnit 4.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, I missed the JUnit 4 requirement on the 3.0.x branch. Both test methods are now public. Thank you for catching this!

Fixes spring-projectsgh-1038

Signed-off-by: config25 <yhkim052556@naver.com>
@config25 config25 force-pushed the fix/cookie-equals-sign-parsing branch from ac1b011 to f0a2e34 Compare April 13, 2026 07:13
Comment on lines +108 to +110
if (separator == -1) {
return new RequestCookie(header, "");
}
Copy link
Copy Markdown
Member

@wilkinsona wilkinsona Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. To have an empty-string value, I believe the header's value would have to be malformed=. Without the equals sign, there should be no cookie at all as the header is invalid. I think failing in this case is fine so I'd just remove lines 108-110.

@wilkinsona wilkinsona changed the title WebTestClientRequestConverter mishandles cookies whose value contains = and fails on cookie headers without = WebTestClientRequestConverter mishandles cookies whose value contains = Apr 13, 2026
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 this pull request may close these issues.

3 participants