- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Description
daniel carter opened SPR-11401 and commented
The UrlTag advises that it will URL encode template URI variables
I have a path URL in my controller
@RequestMapping(value = "/circuit/{id}/view", method = RequestMethod.GET)And the following in my jsp to call it:
<spring:url var="viewUrl" value="/circuit/{circuitId}/view" >
    <spring:param name="circuitId"  value="my/Id"/>
  </spring:url>If for example id=my/Id then the tag writes out /circuit/my/Id/view
This obviously does not work as it fails to match the request mapping.
It should be URL encoding the path variable to write out /circuit/my%2FId/view
The problem is that / has a special meaning in paths, and thus needs to be escaped in path variables, but UrlTag.replaceUriTemplateParams calls UriUtils.encodePath(...) and ultimately at line 480 of HierarchicalUriComponents it decides that '/' does not need encoding
PATH {
		@Override
		public boolean isAllowed(int c) {
			return isPchar(c) || '/' == c;
		}
	},
Looks like UrlTag should be calling UriUtils.encodePathSegment(...) instead.
Affects: 3.2.5
Issue Links:
- Spring tag library does not encode a URI correctly [SPR-10303] #14937 Spring tag library does not encode a URI correctly ("is duplicated by")
- Support advanced URI Template Syntax [SPR-10505] #15137 Support advanced URI Template Syntax
- Spring request mapping annotation does not map an encoded URI correctly [SPR-10306] #14940 Spring request mapping annotation does not map an encoded URI correctly