Description
@RequestParams
(i.e. HTTP query parameters) with leading or trailing spaces, including single parameters or delimited parameters, are trimmed when mapping them to a collection. It is likely this happens for other cases. A query parameter with a leading/trailing space is a perfectly reasonable construct provided it is encoded correctly. However by the time it gets into a controller, the space(s) have been trimmed.
I can see this happening in at least two Boot classes, and there are probably more:
StringToCollectionConverter
DelimitedStringToCollectionConverter
Simply removing the trim()
calls is not the right choice as these are also used for parsing application.yml
, and possibly have other uses. I suggest these converters should accept a trim? parameter at construction time, and the WebConversionService
be given its own instances of the converters with trim=false
so query params with leading/trailing spaces can be properly passed. Something like that anyway...