CCCLL opened a new issue, #16559:
URL: https://github.com/apache/dubbo/issues/16559

   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   Dubbo Java 3.3.0 to 3.3.6 and the `3.3` branch (1afcdf7883), OpenJDK 21, 
macOS.
   
   ### Steps to reproduce this issue
   
   A Triple REST service with a path variable, in any of the three supported 
styles. Each method returns the variable as it receives it.
   
   ```java
   @Mapping("/basic")
   public interface BasicApi {
       @Mapping("/users/{name}")
       String user(@Param(value = "name", type = ParamType.PathVariable) String 
name);
   
       @Mapping("/matrix/{seg}")
       String matrix(@Param(value = "seg", type = ParamType.PathVariable) 
String seg,
                     @Param(value = "tag", type = ParamType.MatrixVariable) 
String tag);
   }
   
   @RequestMapping("/spring")
   public interface SpringApi {
       @GetMapping("/users/{name}")
       String user(@PathVariable("name") String name);
   }
   
   @Path("/jaxrs")
   public interface JaxrsApi {
       @GET
       @Path("/users/{name}")
       String user(@PathParam("name") String name);
   }
   ```
   
   ```
   GET /basic/users/[email protected]    -> "john [email protected]"
   GET /spring/users/[email protected]   -> "john [email protected]"
   GET /jaxrs/users/[email protected]    -> "john [email protected]"
   GET /basic/matrix/x;tag=1.0+build        -> "1.0 build"
   GET /basic/users/a%2Bb                   -> "a+b"
   ```
   
   Same result with the released 3.3.0 and 3.3.6 jars.
   
   ### What you expected to happen
   
   `[email protected]` and `1.0+build`.
   
   In a URL path, `+` is an ordinary character (RFC 3986, section 3.3). Only 
`application/x-www-form-urlencoded` data, i.e. query strings and form bodies, 
uses it for a space. Spring MVC (`@PathVariable`, decoded with 
`UriUtils.decode`), RESTEasy (`@PathParam`, `Encode.decodePath`) and 
`java.net.URI#getPath()` all keep the `+`.
   
   The values go through `RequestUtils.decodeURL`, which is 
`URLDecoder.decode`, a form decoder: its Javadoc says "The plus sign "+" is 
converted into a space character". It is used for path and matrix variables in 
`RequestUtils.getPathVariable`, `RequestUtils.parseMatrixVariables`, 
`ParamArgumentResolver` (`@Param`), `PathVariableArgumentResolver` (Spring) and 
`PathParamArgumentResolver` (JAX-RS), since 3.3.0 (#13607, #14334). Query 
parameters and form bodies are decoded correctly. 
`URLStrParser.decodeComponent` in dubbo-common already makes this distinction 
with its `isPath` flag.
   
   ### Anything else
   
   It happens every time a path or matrix variable contains a raw `+`, for 
example plus-addressed e-mail addresses, phone numbers such as `+86...`, or 
versions such as `1.0+build.5`. The method silently receives a different value.
   
   I compared `RequestUtils.decodeURL` with Spring's `UriUtils.decode`, 
RESTEasy 3.15.6 `Encode.decodePath` and `java.net.URI#getPath()` on 153 path 
segments (every non-alphanumeric RFC 3986 `pchar` sent raw, every byte from 
0x20 to 0x7E percent-encoded, and some UTF-8): the three references agree with 
each other on all of them, and Dubbo differs from them only on the 7 inputs 
that contain a raw `+`.
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to