{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/226","repository_url":"https://api.github.com/repos/spring-projects/spring-hateoas","labels_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/226/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/226/comments","events_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/226/events","html_url":"https://github.com/spring-projects/spring-hateoas/issues/226","id":40011719,"number":226,"title":"Encoded forward slashes in URL cause wrong links","user":{"login":"meyertee","id":270718,"avatar_url":"https://avatars.githubusercontent.com/u/270718?v=3","gravatar_id":"","url":"https://api.github.com/users/meyertee","html_url":"https://github.com/meyertee","followers_url":"https://api.github.com/users/meyertee/followers","following_url":"https://api.github.com/users/meyertee/following{/other_user}","gists_url":"https://api.github.com/users/meyertee/gists{/gist_id}","starred_url":"https://api.github.com/users/meyertee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meyertee/subscriptions","organizations_url":"https://api.github.com/users/meyertee/orgs","repos_url":"https://api.github.com/users/meyertee/repos","events_url":"https://api.github.com/users/meyertee/events{/privacy}","received_events_url":"https://api.github.com/users/meyertee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2014-08-11T23:36:27Z","updated_at":"2016-09-29T02:17:28Z","closed_at":null,"body":"For example when calling this URL: `http://localhost:8080/things/%2Fsome%2Fthing`, then this is produced in the controller method:\r\n\r\n    @RequestMapping(value = \"/{id}\", produces = MediaType.APPLICATION_JSON_VALUE)\r\n    @ResponseBody\r\n    public ResponseEntity<ThingResource> get(@PathVariable(\"id\") String id) {\r\n        Link link = linkTo(ThingController.class).slash(id).withSelfRel();\r\n        System.out.println(link.getHref());\r\n        //...\r\n    }\r\n\r\nIt prints `http://localhost:8080/things/some/thing/things/some/thing` where it should produce `http://localhost:8080/things/%2Fsome%2Fthing`.\r\n\r\nThere are two problems:\r\n1. It takes the decoded path-variable as the base-path of the request mapping. This only happens when there is a leading `%2F`. If the leading character is another one the mapping works\r\n2. It appends the id unencoded where it should be encoded (I guess)\r\n\r\nI'm well aware that slashes in path variables are problematic, but they do work in Spring MVC now, see https://jira.spring.io/browse/SPR-7919 & https://jira.spring.io/browse/SPR-11101\r\n\r\nThe problem could be in `ServletUriComponentsBuilder.fromServletMapping(HttpServletRequest)` where a `UrlPathHelper` is instantiated which defaults to `urlDecode = true`. The fix for having encoded slashes in Spring MVC is to set `urlDecode = false`, I guess that's related. Maybe that could be made configurable?"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/comments/250353437","html_url":"https://github.com/spring-projects/spring-hateoas/issues/226#issuecomment-250353437","issue_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/226","id":250353437,"user":{"login":"SandyJone","id":12883015,"avatar_url":"https://avatars.githubusercontent.com/u/12883015?v=3","gravatar_id":"","url":"https://api.github.com/users/SandyJone","html_url":"https://github.com/SandyJone","followers_url":"https://api.github.com/users/SandyJone/followers","following_url":"https://api.github.com/users/SandyJone/following{/other_user}","gists_url":"https://api.github.com/users/SandyJone/gists{/gist_id}","starred_url":"https://api.github.com/users/SandyJone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SandyJone/subscriptions","organizations_url":"https://api.github.com/users/SandyJone/orgs","repos_url":"https://api.github.com/users/SandyJone/repos","events_url":"https://api.github.com/users/SandyJone/events{/privacy}","received_events_url":"https://api.github.com/users/SandyJone/received_events","type":"User","site_admin":false},"created_at":"2016-09-29T02:17:28Z","updated_at":"2016-09-29T02:17:28Z","body":"the same question "}}
{"actor":{"display_login":"SandyJone"}}