Spring Framework
  1. Spring Framework
  2. SPR-6164

a Uri Value is incorrectly extracted if it contains '.'.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 3.0 M4, 3.0 RC1
    • Fix Version/s: 3.1 RC1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Suppose we have the controller request mapping as the following

      @RequestMapping(value = "/my/

      {vari}", method = RequestMethod.GET)
      @ResponseBody
      public String getVari(@PathVariable String vari) { System.out.println("vari=" + vari); return vari; }


      If a request such as "http://localhost/myapp/my/abc.mycontroller.com" is submitted, the actually value of 'vari' obtained by Spring API only returns 'abc.mycontroller'.

      Further investigation turns out the issue is at line 564 in https://src.springframework.org/svn/spring-framework/tags/spring-framework-3.0.0.RC1/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java. The pattern generated by the line results in "{vari}

      .*". With the 'pathMatcher' (the matcher used at line 565) object created by AntPathStringMatcher("

      {vari}

      .*", "abc.mycontroller.com", map), the value of 'vari' will be 'abc.mycontroller' in the 'map' variable after executing line 566.

        Issue Links

          Activity

          Hide
          Rossen Stoyanchev added a comment -

          The new RequestMappingHandlerMapping in Spring 3.1 now provides an option to disable pattern matching by suffix, which does not affect matching to URLs with a trailing slash as described SPR-5636.

          There is work planned for Spring 3.2, which will provide a better alternative to turning pattern matching off completely by checking against a list of configured suffix types. This is described in SPR-8474.

          Show
          Rossen Stoyanchev added a comment - The new RequestMappingHandlerMapping in Spring 3.1 now provides an option to disable pattern matching by suffix, which does not affect matching to URLs with a trailing slash as described SPR-5636 . There is work planned for Spring 3.2, which will provide a better alternative to turning pattern matching off completely by checking against a list of configured suffix types. This is described in SPR-8474 .
          Hide
          Rossen Stoyanchev added a comment -

          Related issue SPR-7632 is now resolved providing a better solution for this issue. There should be no need to disable suffix pattern matching any more as long you have configured valid file extensions.

          Show
          Rossen Stoyanchev added a comment - Related issue SPR-7632 is now resolved providing a better solution for this issue. There should be no need to disable suffix pattern matching any more as long you have configured valid file extensions.
          Hide
          Daniel Serodio added a comment -

          @Rossen, SPR-7632 is for Spring 3.2, which isn't release yet. What is the suggested fix/workaround for Spring 3.1 users?

          Show
          Daniel Serodio added a comment - @Rossen, SPR-7632 is for Spring 3.2, which isn't release yet. What is the suggested fix/workaround for Spring 3.1 users?
          Hide
          Saurabh added a comment -

          It is pretty simple just add ":.+" with your parameter like below:

          here username is e-mail id

          @RequestMapping(value = "checkuser/

          {username:.+}

          " , method=RequestMethod.GET)
          @ResponseBody
          boolean getUserName(@PathVariable("username") String userName)

          { boolean isUserAvailable = userDao.checkAvailable(userName); return isUserAvailable; }

          I am passing value from URL like :
          http://localhost:8081/user/checkuser/test@test.com

          Show
          Saurabh added a comment - It is pretty simple just add ":.+" with your parameter like below: here username is e-mail id @RequestMapping(value = "checkuser/ {username:.+} " , method=RequestMethod.GET) @ResponseBody boolean getUserName(@PathVariable("username") String userName) { boolean isUserAvailable = userDao.checkAvailable(userName); return isUserAvailable; } I am passing value from URL like : http://localhost:8081/user/checkuser/test@test.com
          Hide
          sandip added a comment -

          I am using version 3.2.4 of spring and still facing same issue , do i need to do some more configurations ?

          Show
          sandip added a comment - I am using version 3.2.4 of spring and still facing same issue , do i need to do some more configurations ?

            People

            • Assignee:
              Rossen Stoyanchev
              Reporter:
              Zhou Wu
              Last updater:
              sandip
            • Votes:
              2 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                29 weeks, 2 days ago

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 0.1d
                0.1d