URIEditor prevents configuring URIs with encoded # sign #34262
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: waiting-for-feedback
We need additional information before we can continue
status: waiting-for-triage
An issue we've not yet triaged or decided on
I have a ConfigurationProperties class containing a property of type
java.net.URI
.If I configure a value of
file:///C:/some/path/with/#/in/it
it (correctly) gets converted to a URI with a fragment component (which is not what I need in this case).However, if I configure the value as a correctly encoded URI like this
file:///C:/some/path/with/%23/in/it
, It (incorrectly) gets converted to this URI:file:///C:/some/path/with/%2523/in/it
.I don't see a way to configure this URI so it gets bound corrrectly.
The reason for this is that the
org.springframework.beans.propertyeditors.URIEditor
tries to guess which part of the URI is correctly encoded and which isn't which is a task that's impossible to do correctly for all cases.This has been improved upon several times #10673, #21123, #11743 but I think the approach is fundamentally flawed and the URIEditor should just not try to fix incorrectly encoded URIs by default.
The best workaround I could find was to use URLs instead of URIs.
The text was updated successfully, but these errors were encountered: