Skip to content

Decode URI template variables if the AbstractHandlerMethodMapping.setUrlDecode() property is set to false [SPR-6951] #11616

Closed

Description

@spring-projects-issues

Rusty Weneck opened SPR-6951 and commented

When determining which method of a controller to invoke it can be important to not decode url encodings, especially if the data on the REST request path contains the / (forward slash) character. However once this data is passed to the method as a parameter it would be nice to have it restored to its original encoding. I propose adding an additional boolean which optionally url decodes the return value from AnnotationMethodHandlerAdapter.ServletHandlerMethodInvoker.resolvePathVariable . This issues is particularly tricky as AnnotationMethodHandlerAdapter.ServletHandlerMethodInvoker is a private inner class and cannot easily be overridden.


Affects: 3.0.1

Attachments:

Issue Links:

Referenced from: commits 0105c5e

Activity

  1. spring-projects-issues commented on Mar 5, 2010

    @spring-projects-issues
    CollaboratorAuthor

    Rusty Weneck commented

    Patch to achieve this.

  2. spring-projects-issues commented on Dec 16, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Path variables are actually looked up in a Map<String, String> saved as a request attribute (HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE) by the DefaultAnnotationHandlerMapping (or the RequestMappingHandlerMapping in Spring 3.1). Since the RequestMappingHandlerMapping already has a setUrlDecode(boolean) property, it should know whether URI variables are decoded or not and has the possibility to decode them before preparing the map. Then you only need to set the urlDecode property only once. Do you see any reason why this shouldn't be done whenever urlDecode=false?

  3. spring-projects-issues commented on Dec 16, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Assigning tentatively for resolution in 3.2 also modifying the title (was: "Add decodePathVariable option to AnnotationMethodHandlerAdapter").

  4. spring-projects-issues commented on May 17, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Resolving this as duplicate even though it was opened earlier since #13736 happened to be fixed first.

  5. added
    type: enhancement
    status: duplicate
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webstatus: duplicatetype: enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions