Description
Nick Verbeck opened SPR-14080 and commented
This plays in part with #18266 but is more do to the nature of how DefaultCorsProcessor does its checks.
With the DefaultCorsProcessor auto on. It will always trip the check at line 71 "WebUtils.isSameOrigin(serverRequest)" of DefaultCorsProcessor even if I've already dealt with CORS headers within my own filter beforehand.
However this is not the core issue, an issue that I'm dealing with now. Because this check uses the java.net.URI class to do its parsing its now requiring super strict Request URIs against the webapp. Which is resulting in a number of rejected requests against our app.
The other issue here isn't just the strict nature of URI but just the general use of it in the first place. Its way to overweight for a large number of things its being used for and results in slowness within the app. As well as its suffers from the Charset lock issue at high concurrency. (Nice write-up from the Evernote team on that issue here https://blog.evernote.com/tech/2011/06/21/fast-string-handling-a-frayed-knot/)
Currently the only work around to this is to wrap the HttpServletRequest and hide the Origin header from above. So that the check on line 64 "!CorsUtils.isCorsRequest(request)" will pass and stop further processing.
Ideally it would be great to be able to disable DefaultCorsProcessor at the very least. If anything for the nature of giving the developer the choice not making it for them. However the true solution would be to stop using URI for parsing just a host and port and use a simple regex or string token. As this would still let DefaultCorsProcessor be used.
Affects: 4.2.5
Issue Links:
- Recent ServletServerHttpRequest.getURI() change breaks CORS requests with encoded characters [SPR-14248] #18821 Recent ServletServerHttpRequest.getURI() change breaks CORS requests with encoded characters ("is duplicated by")
- Enable/Disable Spring CORS option [SPR-13691] #18266 Enable/Disable Spring CORS option
- NPE was occurred at WebUtils.isSameOrigin [SPR-14305] #18877 NPE was occurred at WebUtils.isSameOrigin
Referenced from: commits 6807bcb, 8991319, abe7345, 9a41774, a19be75, 9a52c81