Skip to content

XMLHttpRequest: fix a bug where Access-Control-Allow-Origin: * was not handled correctly#1098

Merged
rbri merged 1 commit intoHtmlUnit:masterfrom
duonglaiquang:duong_xhr
Mar 12, 2026
Merged

XMLHttpRequest: fix a bug where Access-Control-Allow-Origin: * was not handled correctly#1098
rbri merged 1 commit intoHtmlUnit:masterfrom
duonglaiquang:duong_xhr

Conversation

@duonglaiquang
Copy link
Contributor

This PR does the following

Addresses CORS preflight handling in HtmlUnit by correcting the isPreflightAuthorized method in XMLHttpRequest to properly recognize the wildcard * value for the Access-Control-Allow-Headers response header.

Problem

When a server responds to a CORS preflight request with Access-Control-Allow-Headers: *, HtmlUnit does not recognize this as a wildcard. Instead, it treats * as a literal header name and adds it to the set of allowed header names. This causes the preflight authorization check to fail for any non-simple headers, even though the server intended to allow all of them.

@rbri
Copy link
Member

rbri commented Mar 12, 2026

@duonglaiquang any chance to have a test for this?

@duonglaiquang
Copy link
Contributor Author

@rbri i have added a test could you take a look

@sonarqubecloud
Copy link

@rbri rbri merged commit 240506e into HtmlUnit:master Mar 12, 2026
8 checks passed
@rbri
Copy link
Member

rbri commented Mar 12, 2026

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants